Question Open button for tabcontrol

Eric_03

Member
Joined
Jul 25, 2022
Messages
14
Location
France
Programming Experience
Beginner
Hello,

I would like from a button on the Excel ribbon to access page 1 or 2 of the pane directly. Can you please help me in my process.

Ruban.png



Volet Micro.PNG


C#:
using Microsoft.Office.Tools.Ribbon;
using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AE
{
    public partial class Ribbon1
    {
        private readonly ActionsPaneControl1 TaskPane = new ActionsPaneControl1();
     

        private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
        {

        }


        private void btServeur_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
            TaskPane.Show();
        }

        private void btFlux_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
            TaskPane.Show();
            tabControl1.SelectedIndex = 1;  <= error?
        }
    }
}

When I finish my project, I can make it available to the community if you wish.

My project is to basically provide two functionalities to the Excel document:
- Synchronization (using WinSCP)
- Uncompress tar.gz

VBA code is also running in the workbook to work with text files

Thanks
 
Last edited:
Solution
Hello,

Not finding the solution, I reviewed the design of my project. I added two buttons in the pane that allow me to navigate in it

Ruban2.png


Volet.PNG



Volet2.PNG


C#:
        private void btSuivantP1_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 1;
        }

        private void btRetourP2_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 0;
        }


Eric

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,698
Location
Chesapeake, VA
Programming Experience
10+
What error are you getting?
 

Eric_03

Member
Joined
Jul 25, 2022
Messages
14
Location
France
Programming Experience
Beginner
Excuse me,

Error : The name "tabControl1" does not exist in the current context.

I don't know how to declare it.

I'm trying to adapt this video:


to my needs:

Thanks
 

Eric_03

Member
Joined
Jul 25, 2022
Messages
14
Location
France
Programming Experience
Beginner
Hello,

Not finding the solution, I reviewed the design of my project. I added two buttons in the pane that allow me to navigate in it

Ruban2.png


Volet.PNG



Volet2.PNG


C#:
        private void btSuivantP1_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 1;
        }

        private void btRetourP2_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = 0;
        }


Eric
 
Solution

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
4,643
Location
Sydney, Australia
Programming Experience
10+
Did you add a control named tabControl1 to your class? We're not about to watch a whole video tutorial and hope we pick something up. How about you provide a timestamp for where that control is added and show us in your code where you have done that?
 

Eric_03

Member
Joined
Jul 25, 2022
Messages
14
Location
France
Programming Experience
Beginner
Hi,

Regarding the video, I'm just taking inspiration from it in these broad outlines.

I don't understand: "How about you provide a timestamp for where that control is added and show us in your code where you have done that"

Do you want the new or old version?

I can make available if you wish the code of my first realization but I find that the new version is more ergonomic.

I am far from having finished my project even if this one is very small. I think I will still need your help.

Do you want me to make my project available on github so you can watch it? There is very little code.

Thanks

Eric
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
4,643
Location
Sydney, Australia
Programming Experience
10+
I want you to show us where you have added tabControl1. The error message tells you and us that there is no such thing. You obviously think that's wrong so you should be able to show us where it's declared. If you can't show us then that's probably because it doesn't exist. If you expect to be able to use a TabControl then you have to actually create a TabControl to use. I don't really know how to say it any plainer.
 

Eric_03

Member
Joined
Jul 25, 2022
Messages
14
Location
France
Programming Experience
Beginner
Since this morning I am trying to find the solution.

I hope to make myself better understood by posting these images

tabcontrol1.PNG



tabpage1.PNG


tabpage2.PNG



C#:
using Microsoft.Office.Tools.Ribbon;
using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;


namespace AE
{
    public partial class Ribbon1
    {
        private readonly ActionsPaneControl1 TaskPane = new ActionsPaneControl1();
        private readonly TabControl tabControl1 = new TabControl();

        private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
        {

        }

        private void btPane_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
            TaskPane.Show();
        }

        private void btServeur_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
            tabControl1.SelectedIndex = 0;
        }

        private void btFlux_Click(object sender, RibbonControlEventArgs e)
        {
            Globals.ThisWorkbook.Application.DisplayDocumentActionTaskPane = true;
            tabControl1.SelectedIndex = 1;
        }
    }
}

Eric
 
Last edited:
Top Bottom