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. Form.Show() and TabControl tab page changed

Form.Show() and TabControl tab page changed

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 2 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.
  • C Offline
    C Offline
    C Scharbe
    wrote on last edited by
    #1

    I have the following problem -I created a form with an tab control -I the tab control contains (minimum) 2 tab pages -In the second (non selected) tab page i have a control -And there is another formular (irrelevant content) #region PREPERATION // instanciate a form Form f = new Form(); // instanciate a tab control TabControl t = new TabControl(); // instanciate tab page 1 TabPage tp1 = new TabPage("page1"); // instanciate tab page 2 TabPage tp2 = new TabPage("page2"); // instanciate a control (sample: button) Button b = new Button(); b.Size = new Size(100, 20); // add the control to the tab page tp2.Controls.Add(b); // add the tab pages t.TabPages.Add(tp1); t.TabPages.Add(tp2); // add the tabcontrol this.Controls.Add(t); t.BringToFront(); #endregion PREPERATION When i first open the child-form with Show() and then select the tab page with the control the parent-form is focused again. // show the form f.Show(); // select the tab with the control t.SelectedIndex = 1; How can i force the child-form to keep its focus, while the parent change the tab page? I don't want to use ShowDialog() or Show(this). Is this a bug or a feature of the tab control (tab page)? (Is the only way to fix it, changing the order of the source code?)

    S C 2 Replies Last reply
    0
    • C C Scharbe

      I have the following problem -I created a form with an tab control -I the tab control contains (minimum) 2 tab pages -In the second (non selected) tab page i have a control -And there is another formular (irrelevant content) #region PREPERATION // instanciate a form Form f = new Form(); // instanciate a tab control TabControl t = new TabControl(); // instanciate tab page 1 TabPage tp1 = new TabPage("page1"); // instanciate tab page 2 TabPage tp2 = new TabPage("page2"); // instanciate a control (sample: button) Button b = new Button(); b.Size = new Size(100, 20); // add the control to the tab page tp2.Controls.Add(b); // add the tab pages t.TabPages.Add(tp1); t.TabPages.Add(tp2); // add the tabcontrol this.Controls.Add(t); t.BringToFront(); #endregion PREPERATION When i first open the child-form with Show() and then select the tab page with the control the parent-form is focused again. // show the form f.Show(); // select the tab with the control t.SelectedIndex = 1; How can i force the child-form to keep its focus, while the parent change the tab page? I don't want to use ShowDialog() or Show(this). Is this a bug or a feature of the tab control (tab page)? (Is the only way to fix it, changing the order of the source code?)

      S Offline
      S Offline
      snorkie
      wrote on last edited by
      #2

      Try tp2.Select(); You don't want to select the tab control, but the actual tab with the control on it. Hogan

      C 1 Reply Last reply
      0
      • S snorkie

        Try tp2.Select(); You don't want to select the tab control, but the actual tab with the control on it. Hogan

        C Offline
        C Offline
        C Scharbe
        wrote on last edited by
        #3

        It does not work. It don't show the tab page (tp2).

        1 Reply Last reply
        0
        • C C Scharbe

          I have the following problem -I created a form with an tab control -I the tab control contains (minimum) 2 tab pages -In the second (non selected) tab page i have a control -And there is another formular (irrelevant content) #region PREPERATION // instanciate a form Form f = new Form(); // instanciate a tab control TabControl t = new TabControl(); // instanciate tab page 1 TabPage tp1 = new TabPage("page1"); // instanciate tab page 2 TabPage tp2 = new TabPage("page2"); // instanciate a control (sample: button) Button b = new Button(); b.Size = new Size(100, 20); // add the control to the tab page tp2.Controls.Add(b); // add the tab pages t.TabPages.Add(tp1); t.TabPages.Add(tp2); // add the tabcontrol this.Controls.Add(t); t.BringToFront(); #endregion PREPERATION When i first open the child-form with Show() and then select the tab page with the control the parent-form is focused again. // show the form f.Show(); // select the tab with the control t.SelectedIndex = 1; How can i force the child-form to keep its focus, while the parent change the tab page? I don't want to use ShowDialog() or Show(this). Is this a bug or a feature of the tab control (tab page)? (Is the only way to fix it, changing the order of the source code?)

          C Offline
          C Offline
          C Scharbe
          wrote on last edited by
          #4

          Does anyone have another idea?

          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