locked
Dynamically add tab control RRS feed

  • Question

  • hi guys,

    I want to add tab controls dynamically based on the dialog like it depends on user to how many tabs he want to add and i have to set the title of the tab also.

    Like on load event of the form it will ask the user to select the tabs based on the selection it should generate the tabs.
    Monday, December 17, 2007 9:41 AM

Answers

  • hi put the following code where you want just set the value of the integer how much you want tabs..

     

     

    Code Block

     

    int tabsToCreate = 3; //just change the value according your requirement

     

    //Assume that there is "tabControl1" is already on the form

     

    //Clear the TabPages everytime

    tabControl.TabPages.Clear();

     

    for (int i = 0; i < tabsToCreate; i++)

    {

    TabPage tabPage = new TabPage("Title" + i.ToString());

    tabControl.TabPages.Add(tabPage);

    }

     

     



    Chintankumar Patel ( MCSD .Net )
    http://www.nineon.com
    Monday, December 17, 2007 11:20 AM

All replies

  • hi put the following code where you want just set the value of the integer how much you want tabs..

     

     

    Code Block

     

    int tabsToCreate = 3; //just change the value according your requirement

     

    //Assume that there is "tabControl1" is already on the form

     

    //Clear the TabPages everytime

    tabControl.TabPages.Clear();

     

    for (int i = 0; i < tabsToCreate; i++)

    {

    TabPage tabPage = new TabPage("Title" + i.ToString());

    tabControl.TabPages.Add(tabPage);

    }

     

     



    Chintankumar Patel ( MCSD .Net )
    http://www.nineon.com
    Monday, December 17, 2007 11:20 AM
  • hi thank you very much for ur answer it was really help full. I have added tabs and controls also like picbox datagrid but  here i am stuck while assigning the images from the database to dynamic added tabs picbox
    Wednesday, December 19, 2007 5:55 AM
  • In this thread, we are mainly discussing about "Add TabControl dynamically", as indicated by the first post and the title.
    Since your new question "How to assign the image to a DataGrid from DataBase" is not directly related to the original issue, it would be best if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.
    Thank you for your understanding.

     

    Friday, December 21, 2007 1:22 AM