Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Disabling a TabPage in TabControl

Disabling a TabPage in TabControl

Scheduled Pinned Locked Moved C#
csharpjsonhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jagan79
    wrote on last edited by
    #1

    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.

    S 1 Reply Last reply
    0
    • J jagan79

      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.

      S Offline
      S Offline
      sreejith ss nair
      wrote on last edited by
      #2

      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 ]

      J 1 Reply Last reply
      0
      • S sreejith ss nair

        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 ]

        J Offline
        J Offline
        jagan79
        wrote on last edited by
        #3

        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

        R 1 Reply Last reply
        0
        • J jagan79

          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

          R Offline
          R Offline
          Ruchi Gupta
          wrote on last edited by
          #4

          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 event private 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

          J 1 Reply Last reply
          0
          • R Ruchi Gupta

            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 event private 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

            J Offline
            J Offline
            jagan79
            wrote on last edited by
            #5

            Thank you ruchi , that was helpful

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups