Disabling a TabPage in TabControl
-
Hello ppl, I am using a tabcontrol for desktop client application(C#/ADO.Net),which has a parser in one tab and report Generator as another tab page. I have used multithreading and assigned a worker thread(say backGroundThread)for the application to parse values - So that the application would repaint itself whenever the user switches back and forth between any window and the application. But as i have used Threading, when parsing is in progress, the user is able to navigate through tabs. So I have to disable the rest of the tabpages in Tabcontrol when parsing in progress. I tried to reset the tabpage to Parser tab(Sender TabPage) in TabControl_SelectedIndexChanged(object sender, System.EventArgs e) How do I capture the tabpage(Sender TabPage). i.e name of the tabpage from which the user tried to navigate? I tried to typecast the sender object to get the sender tabpage.BUt i could not get a break through in identifying the source tabpage. System.Windows.Forms.TabControl homeTab = (System.Windows.Forms.TabControl)sender; kindly help me to overcome this problem. Thanks, Cheers, Jagan.
-
Hello ppl, I am using a tabcontrol for desktop client application(C#/ADO.Net),which has a parser in one tab and report Generator as another tab page. I have used multithreading and assigned a worker thread(say backGroundThread)for the application to parse values - So that the application would repaint itself whenever the user switches back and forth between any window and the application. But as i have used Threading, when parsing is in progress, the user is able to navigate through tabs. So I have to disable the rest of the tabpages in Tabcontrol when parsing in progress. I tried to reset the tabpage to Parser tab(Sender TabPage) in TabControl_SelectedIndexChanged(object sender, System.EventArgs e) How do I capture the tabpage(Sender TabPage). i.e name of the tabpage from which the user tried to navigate? I tried to typecast the sender object to get the sender tabpage.BUt i could not get a break through in identifying the source tabpage. System.Windows.Forms.TabControl homeTab = (System.Windows.Forms.TabControl)sender; kindly help me to overcome this problem. Thanks, Cheers, Jagan.
Below mentioned code will help you to get the index of the Tab page which have the focus.
private void tabPage1_Click(object sender, EventArgs e) { TabPage tb=sender as TabPage; MessageBox.Show("Index is : "+tabControl1.TabPages.IndexOf(tb)); }
Using this code you can achive your requirement.:-O Sreejith Nair [ My Articles ] -
Below mentioned code will help you to get the index of the Tab page which have the focus.
private void tabPage1_Click(object sender, EventArgs e) { TabPage tb=sender as TabPage; MessageBox.Show("Index is : "+tabControl1.TabPages.IndexOf(tb)); }
Using this code you can achive your requirement.:-O Sreejith Nair [ My Articles ]Hello sreejith, Thanks for replying back. But i donot want the name of tab which have the focus. Let me expain with an example. Say there are three tabpages - Tabpage tpA,Tabpage tpB,Tabpage tpC in a tabControl and currently user is in Tabpage tpA and clicked on tpB. I want to capture the name of the tab from which the user moved to tpB (either from tbA or tpC).. in otherwords my lastselected tabpage and not the current selected tabpage. Hope i am clear in explaining my problem. Cheers, Jagan
-
Hello sreejith, Thanks for replying back. But i donot want the name of tab which have the focus. Let me expain with an example. Say there are three tabpages - Tabpage tpA,Tabpage tpB,Tabpage tpC in a tabControl and currently user is in Tabpage tpA and clicked on tpB. I want to capture the name of the tab from which the user moved to tpB (either from tbA or tpC).. in otherwords my lastselected tabpage and not the current selected tabpage. Hope i am clear in explaining my problem. Cheers, Jagan
one way to achive this is keep a global class variable
int lasttabIndex;
At form load time set it to whatever tab you want to open the first time form loads. There after in eventprivate void tabControlDeal_SelectedIndexChanged(object sender, System.EventArgs e) { TabControl ctrl = (TabControl)sender; int x = ctrl.SelectedIndex; //Do decisions on the basis of the value of "lasttabIndex " //at the end do this lasttabIndex = x; }
Hope this helps Ruchi -
one way to achive this is keep a global class variable
int lasttabIndex;
At form load time set it to whatever tab you want to open the first time form loads. There after in eventprivate void tabControlDeal_SelectedIndexChanged(object sender, System.EventArgs e) { TabControl ctrl = (TabControl)sender; int x = ctrl.SelectedIndex; //Do decisions on the basis of the value of "lasttabIndex " //at the end do this lasttabIndex = x; }
Hope this helps Ruchi