启用或禁用选项卡控件中的选项卡页面 [英] enable or disable tab pages in tab control

查看:95
本文介绍了启用或禁用选项卡控件中的选项卡页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好每个人都知道我如何启用或禁用标签控件中的标签页。

例如当我点击按钮tabpage1时禁用并点击其他按钮启用它。 />
谢谢。

解决方案

你好我为每个人找到了解决问题的方法

拳头:

在我的项目中添加一个选项卡控件和一个按钮,并将这两个方法添加到我的项目中:

  public   static   void  EnableTab(TabPage页面, bool  enable)
{
EnableControls(page.Controls,enable);
}
私有 静态 void EnableControls(Control.ControlCollection ctls, bool enable)
{
foreach (控制ctl in ctls)
{
ctl.Enabled = enable;
EnableControls(ctl.Controls,enable);
}
}



然后双击按钮并添加此行以禁用标签页:

< pre lang =c#> private void button1_Click( object sender,EventArgs e)
{
EnableTab(tabControl1.TabPages [tabControl1.SelectedIndex = 0 ],);
}





并且为了启用它我添加了另一个按钮并添加此行以启用标签页:



  private   void  button1_Click( object  sender,EventArgs e)
{
EnableTab(tabControl1.TabPages [tabControl1.SelectedIndex = 0 ], true );
}



资源:

Barnamenevis.org


hi,

关于标签面板



http://www.asp。 net / ajaxlibrary / tabs-control.ashx [ ^ ]



你可以将启用的属性设置为true或false



 受保护  void  btn1_Click( object 发件人,EventArgs e)

{

tab1.Enabled = False
}









这可以帮到你



快乐编码


hello every one do you know how i can enable or disable tab pages in tab control.
for example when i click on the button tabpage1 is disable and click on other button enable it.
thank you.

解决方案

hello every one i found a solution for my problem
fist:
add a tab control,and a button on my project and the add this two methods to my project:

public static void EnableTab(TabPage page, bool enable)
{
    EnableControls(page.Controls, enable);
}
private static void EnableControls(Control.ControlCollection ctls, bool enable)
{
    foreach (Control ctl in ctls)
    {
        ctl.Enabled = enable;
        EnableControls(ctl.Controls, enable);
    }
}


and then double click on the button and add this line to disable tab page :

private void button1_Click(object sender, EventArgs e)
        {
            EnableTab(tabControl1.TabPages[tabControl1.SelectedIndex = 0], false);
        }



and for enable it i add an other button and add this line to enable tab page:

private void button1_Click(object sender, EventArgs e)
        {
            EnableTab(tabControl1.TabPages[tabControl1.SelectedIndex = 0], true);
        }


resource:
Barnamenevis.org


hi,
link regarding Tab panels

http://www.asp.net/ajaxlibrary/tabs-control.ashx[^]

you can set the enabled property true or false

protected void btn1_Click(object sender, EventArgs e)

{

tab1.Enabled=False
}





this may help you

Happy coding


这篇关于启用或禁用选项卡控件中的选项卡页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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