In a C# GUI program how do you move a tab control to the front on the click of an object?
I have a picture box on the main tab, when the user clicks on the picture box, I want the second tab to be pulled forward.
Visual Studio 2005
Cheers.
In a C# GUI program how do you move a tab control to the front on the click of an object?
I have a picture box on the main tab, when the user clicks on the picture box, I want the second tab to be pulled forward.
Visual Studio 2005
Cheers.
Are you trying to select a different tab or bring a TabControl in front of a different control?
If the former, write tabControl.SelectedTab = someTabPage in the picture box's Click event.
If the latter, write tabControl.BringToFront().
To select a different tab, set the SelectedTab index from your handler:
// select the second tab in the control
tabControl1.SelectedTab = tabControl1.TabPages[1];
You want to handle the Click event on the control (add a handler to Control.OnClick) containing the picture, and if you have tabControl and myTabPage is the tab page that you want to be selected after the click, you would use TabControl.SelectedPage:
tabControl.SelectedTab = myTabPage;
In particular, since you refer to the "second tab" then you probably want
tabControl.SelectedTab = tabControl.TabPages[1];