tabcontrol problem ? howto check if a different tab is clicked ?
-
hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.
Mehmet Fatih Akbulut wrote:
on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ?
Yes. Write the following code in tabcontrol's Selected event.
if(e.TabPageIndex == 0) MessageBox(e.TabPge.Name); else if(e.TabPageIndex == 1) MessageBox(e.TabPge.Name);
Regards. _____________________________ Success is not something to wait for, its something to work for. -
hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.
I use the tabcontrol quite a bit in my application, and although you CAN use the index of the tab pages, using the text property gives you a bit more flexibility IMHO. For instance, so far my users have added 3 different tab pages, and deleted 2 of them, and changed the order of them 3 more times. By using the tabControlName.SelectedTab.Text property instead of the index, I don't have to change NEARLY as much code when things change, and my maintenance programmers will have a much easier time too. ;) HTH Gandalf
-
hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.
hy, there is a very simple way to see which tab is selected. Use the SelectedIndex property. for example: if (tabControl1.SelectedIndex == 1) { MessageBox.Show("Tab1"); } you can also use this property to select a tab page: tabControl1.SelectedIndex = 2; If I'm not mistaking the first tab has the index 1 (or 0). Try it.
-
hy, there is a very simple way to see which tab is selected. Use the SelectedIndex property. for example: if (tabControl1.SelectedIndex == 1) { MessageBox.Show("Tab1"); } you can also use this property to select a tab page: tabControl1.SelectedIndex = 2; If I'm not mistaking the first tab has the index 1 (or 0). Try it.
karkster wrote:
If I'm not mistaking the first tab has the index 1 (or 0).
index start from zero (0) for first item. _____________________________ Success is not something to wait for, its something to work for.