Tabcontrol事件 [英] Tabcontrol Events

查看:255
本文介绍了Tabcontrol事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

只是一个问题让我完全难过.

简而言之,如何在更改标签页时隐藏/显示某些控件?
IE.当用户将选项卡1切换到选项卡2时,我想隐藏菜单栏和工具栏.

干杯
Siek

Hi Guys,

Just having an issue that has completely stumped me.

In a nutshell, how to hide/show certain controls when a tabpage is changed?
ie. when the tabpage 1 is switched to tabpage 2 by the users, I want to hide the menustrip and toolbar.

Cheers
Siek

推荐答案

TabControl对象具有一个称为Selected的事件.
选择新选项卡后,将触发此事件.事件参数中包含的对象之一是刚刚选择的TabPage.

因此,在该方法中,您可以检查e.TabPage.Name并查看是否要显示或隐藏控件.
The TabControl object has an event called Selected.

When a new tab is selected, this event fires. One of the objects included in the event''s arguments is the TabPage that was just selected.

So, in the method, you can check e.TabPage.Name and see if you want to show or hide the controls.


我使用TabControl的SelectedIndexChanged事件.确保您正在查看 TabControl 而不是 TabPage 的事件.您可以包含如下代码来检查选择了哪个TabPage:

I use the TabControl''s SelectedIndexChanged Event. Make sure you are looking at events for the TabControl not the TabPage. You can include code that checks which TabPage is selected like this:

Private Sub tcMyTabControl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tcMyTabControl.SelectedIndexChanged
       'If newly selected tab is tabpage2
       If tcMyTabControl.SelectedTab Is tpTabPage2 Then
          'Hide menu/toolbar
       Else
          'Show menu/toolbar           
       End If
End Sub



希望这会有所帮助.



Hope this helps.


这篇关于Tabcontrol事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆