1
votes

I'm looking for solution for my problem. I want to change location for tabcontrol's TabButtons or add control assigned to tabpage but outside TabControl. TabPages are added dynamically. Example:

Form1___________ _ [] X

_______________________

Some TabPage content

Tab1 | Tab2 | Tab3 | < >

TextBox assigned to Tab's
________________________

So if I change tabs by clicking on Tab1,Tab2,Tab3 TabPage + TextBox content should change depending on Tab. The first idea was to put TabButtons on bottom and add ArrayList what contains TextBox content, catch TabControl change tab event and change TextBox content, but there was an issue with editing and adding that content. In few words: I wan't to put TabButtons between 2 controls(for example between two textboxes).Do you have any ideas?

4
It's hard to tell what you want. Can you point to an existing website that does something like this? - egrunin
Oh, I forgot to mention, this is windows application - user1112008
Next example, neowin.net/images/uploaded/winlive-wm-convwin.png but TabButtons(user nicks) should be in emoticon place. - user1112008

4 Answers

1
votes

you can create your own textbox class which inherits from textbox class :

class MyOwnTextBox:TextBox
{
  public int parent_tab;
}

So you can add your textbox by assigning a parent_tab id to them . so in tab button click event , you can do something like that :

foreach(MyOwnTextBox txt in this.Controls)
{
   if(txt.parent_tab==1) txt.visible=false;
}
1
votes

If I understand what you're asking for... You want when you click on a tab, it controls two different things? Like two different text boxes? If that is true, you should be able to do it like this.

foreach (thing in your ArrayList)
{
     TabPage tabPage = new TabPage("Name of tab");            // Add a new tab page
     RichTextBox rtb = new System.Windows.Forms.RichTextBox();//RTF box
     TextBox tb = new System.Windows.Forms.TextBox();         //Text box

     //Set up size, position and properties
     rtb.LoadFile("some/Path/to/a/file");

     //set up size, position of properties
     tb.Text = "Some text I want to display";

     tabPage.Controls.Add(rtb); //Add both boxes to that tab
     tabPage.Controls.Add(tb);

     tabControl1.TabPages.Add(tabPage); //Add that page to the tab control
}

Only thing you should have to mess around with is the layout. And make sure to have the tabControl added with the designer.

0
votes

You could also place the tabs on the left or the right side of your tab control. That is not perfect, but would come closer to your idea than placing them above or below the tab control.

You can add a new tab page dynamically like this

tabControl1.TabPages.Add("My new Tab");
0
votes

I'm not sure I understand exactly what your trying to do. If you want to change the tab from another object, just use:

 TabController.SelectTab(0);

If you want to remove a TabPage and add it to another, use:

 TabController.Controls.Remove(TabPage1);
 TabController2.Controls.Add(TabPage1);

Edit: From further read, I think you want something like this:

 this.TabController.ControlAdded += AddLinksToBottomOfTabs;
 public void mainSettingsTabController_ControlAdded(object sender, ControlEventArgs e)
 {
     //Create label with e.Control.Name as the title and 
     //add it to wherever you want it added.
 }