Tab Questions

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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,
 
M

mat

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top