Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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:
C#
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();
}
 
Share this answer
 
So your after long explaination your short question is: How to programatically select a TabPage ?

Just set the selected page:

C#
tabControl1.SelectedTab = tabPage2;


or index:

C#
tabControl1.SelectedIndex = 1;


After that you may also want to set the Focus on a specific control on that page? -> call Focus() on the control..

Kind regards Johannes
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900