Tab Questions

  • Thread starter Thread starter mat
  • Start date Start date
M

mat

Hi all,

If I have a main form with a TabControl and this method:

protected void NewTab()
{
TabPage newTab;
newTab = new TabPage();
newTab.BackColor = System.Drawing.SystemColors.Window;
newTab.Size = new System.Drawing.Size(498, 400);

RichTextBox richTextBox;
richTextBox = new PoccoRichTextBox();

newTab.Controls.Add(richTextBox);
tabControl.Controls.Add(newTab);
}

This adds a TabPage as I want, but then I find I am stuck not knowing
howto reference things.

How could I expand the above so that I can insert text into the textBox
and bring the tab to the front of the TabControl?

Your help would be great.

Mat
 
Hi,

IIRC that code will give you error, you cannot add a TabPage to the Control
collection of the tabcontrol, you have to use TabPages

In order to select it do
tabcontrol.SelectedIndex = tabControl.TabPages.Count -1;


cheers,
 
Ignacio said:
Hi,

IIRC that code will give you error, you cannot add a TabPage to the Control
collection of the tabcontrol, you have to use TabPages

In order to select it do
tabcontrol.SelectedIndex = tabControl.TabPages.Count -1;


cheers,

Hi Ignacio,

Thank you for your response. I found this useful:
tabcontrol.SelectedIndex = tabControl.TabPages.Count -1;

....but I didn't quite understand this:

you cannot add a TabPage to the Control collection of the tabcontrol,
you have to use TabPages?

It seems to work when I do it??

Mat
 
Back
Top