TabControl:在Button单击事件中加载Tabcontrol [英] TabControl : Loading Tabcontrol in Button click event
问题描述
我开发了Windows Form App,其中我有Tabcontrol1和我的Tabcontrol Tabpage1 TabPage2
现在
例如 - 在我的Tabpage1中我正在加载Xml和Tab Page 2 Textdata
我已经在Button Load-xml和load -Text中为loadXML和LoadTextdata创建了一个事件。
现在当我点击load-xml xml被加载到我的Tabpage1
当我点击加载文本文本被载入我的Tabpage2
现在我想要做的就是当我点击load-xml xml按钮,然后在此选项卡内自动执行.Load xml或Text正在运行,但我必须手动点击特定的选项卡控件,所以请帮我如何进入特定的选项卡控件。
假设:
1.你在WinForm上有一个名为'tabControl1的TabControl
2.'tabControl1有两个TabPages,你已经命名为tabXML和tabText
3.'t abXML里面有一个TextBox(多行设置为'true),命名为'tbXmL
4.'tabText里面有一个TextBox(多行设置为'true),名为' tbText
5.你有两个按钮,'loadXML和'loadText连接到这些Click EventHandlers:private void btnLoadXML_Click( object sender,EventArgs e)
{
// 加载XML
// 您的代码在这里
// tbXML.Text = ?????
tabControl1.SelectedTab = tabXML;
tbXML.Focus();
}
private void btnLoadText_Click( object sender,EventArgs e)
{
// 加载文本
// 您的代码在这里
// tbText.Text = ?????
tabControl1.SelectedTab = tabText;
tbText.Focus();
}
所以你的长期解释你的简短问题是:如何以编程方式选择TabPage
?
只需设置所选页面:
tabControl1 .SelectedTab = tabPage2;
或指数:
tabControl1.SelectedIndex = 1 ;
之后您可能还想将焦点设置在该页面上的特定控件上? - >在控件上调用Focus()
..
亲切问候Johannes
Hallo ,
I have developing Windows Form App where i have Tabcontrol1 and inside my Tabcontrol Tabpage1 TabPage2
now Forexample -- In my Tabpage1 i am loading Xml and Tab Page 2 Textdata
I havew riiten an events for loadXML and LoadTextdata in Button Load-xml and load -Text .
Now when i click on load-xml xml is loaded into my Tabpage1
when i click on load-Text Text is sloaded into my Tabpage2
now what i want to do is when i click on load-xml xml Button, then go automaticcaly inside this tab .Load xml or Text is working but i have to click on particular tab controls manually so please help me how to go inside particular tab control.
Assuming:
1. you have a TabControl named 'tabControl1 on a WinForm
2. 'tabControl1 has two TabPages that you've named tabXML and tabText
3. 'tabXML has a TextBox inside it (multiline set to 'true) named 'tbXmL
4. 'tabText has a TextBox inside it (multiline set to 'true) named 'tbText
5. you have two Buttons, 'loadXML, and 'loadText connected to these Click EventHandlers:private void btnLoadXML_Click(object sender, EventArgs e) { // load the XML // your code goes here // tbXML.Text = ????? tabControl1.SelectedTab = tabXML; tbXML.Focus(); } private void btnLoadText_Click(object sender, EventArgs e) { // load the Text // your code goes here // tbText.Text = ????? tabControl1.SelectedTab = tabText; tbText.Focus(); }
So your after long explaination your short question is: How to programatically select aTabPage
?
Just set the selected page:
tabControl1.SelectedTab = tabPage2;
or index:
tabControl1.SelectedIndex = 1;
After that you may also want to set the Focus on a specific control on that page? -> callFocus()
on the control..
Kind regards Johannes
这篇关于TabControl:在Button单击事件中加载Tabcontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!