加载表单时的Tabpage(Tabcontrol)选择

Tabpage(Tabcontrol) choice when loading form [closed]
2021-05-11
  •  译文(汉语)
  •  原文(英语)

加载包含TabControl的主窗体时,我该怎么办?我想做一些以前显示过的tabPges

通常,我希望在加载tabPges2表单时成为默认设置,而其他tabPges被禁用.

图像

速聊1:
您是从WPF还是Forms询问有关TabControl的问题?
解决过程1

您可以使用选项卡控件的SelectedTab属性设置所选页面:

myTabControl.SelectedTab = tabPage2;
速聊1:
没有选择属性.
速聊2:
我说的是本地WinForms控件.你指的是什么?
速聊3:
抱歉,您说的是真的,我弄错了.
解决过程2

您无法隐藏/显示标签页,因为从MSDN读取

TabPage控件受其容器限制,因此从Control基类继承的某些属性将无效,包括Top,Height,Left,Width,Show和Hide.

TabControl中的选项卡是TabControl的一部分,但不是各个TabPage控件的一部分.TabPage类的成员(例如ForeColor属性)仅影响选项卡页面的客户端矩形,而不影响选项卡.此外,TabPage的Hide方法将不会隐藏该选项卡.若要隐藏选项卡,必须从TabControl.TabPages集合中删除TabPage控件.

因此,Load一旦发生事件,请删除所有标签页,并在以后需要时添加它们.不幸的是,您也不能禁用它们.只有最好的解决方法,请参见此处

How can I when loading the main form in which there is a TabControl I want to do something that used to be displayed tabPges

In general I want to be the default when loading tabPges2 form and other tabPges be disabled.

Image

Talk1:
are you asking about TabControl from WPF or Forms?
Solutions1

You can set the selected page using the tab control's SelectedTab property:

myTabControl.SelectedTab = tabPage2;
Talk1:
There is no property selectedTab.
Talk2:
I am talking about the native WinForms control. What are you referring to?
Talk3:
I'm sorry I made a mistake you're saying is true.
Solutions2

You can't hide/show tab pages because as read from MSDN

TabPage controls are constrained by their container, so some of the properties inherited from the Control base class will have no effect, including Top, Height, Left, Width, Show, and Hide.

The tabs in a TabControl are part of the TabControl but not parts of the individual TabPage controls. Members of the TabPage class, such as the ForeColor property, affect only the client rectangle of the tab page, but not the tabs. Additionally, the Hide method of the TabPage will not hide the tab. To hide the tab, you must remove the TabPage control from the TabControl.TabPages collection.

so on Load event remove all tab pages and add them later when needed. Unfortunately you can't disable them either. There is only not-the-best workaround, see here

转载于:https://stackoverflow.com/questions/20217545/tabpagetabcontrol-choice-when-loading-form

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入