开发者

In a C# GUI program how do you move a tab control to the front on the click of an object?

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().


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];


To select a different tab, set the SelectedTab index from your handler:

// select the second tab in the control
tabControl1.SelectedTab = tabControl1.TabPages[1];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜