CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    2

    Help with SelectedTab

    I am creating an app that uses tabs. I want to be able to add, edit, and delete on each tab. Basically, I am connected to a sql database, and i want to be able add, edit, and delete items in db and bind to the gridview on a specific tab. I have these three buttons outside of the tabs so they can be used for each one. I am trying to figure out how to use SelectedTab so that the tab I am currently on will be the one that gets changed. Any help is appreciated. thanks

  2. #2
    Join Date
    May 2011
    Posts
    1

    Re: Help with SelectedTab

    Id create each tab with a tag, so tab one could have the tag 1 and tab two could have the tag 2 etc..

    Then the following code would loop round the entire tab collection and then all of the control on the selected tab. If someone knows a better way, please correct me.

    string tag = tabControl1.SelectedTab.Tag.ToString();

    foreach (TabPage tab in tabControl1.TabPages)
    {
    if (tab.Tag.ToString() == tag)
    {
    foreach (Control ctrl in tab.Controls)
    {
    if (ctrl.GetType() == typeof(TextBox))
    {
    ctrl.Text = "Tab page updated!";
    }
    }
    }
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured