Adding a control to a tab page

  • Thread starter Thread starter Liz
  • Start date Start date
L

Liz

I am trying to add a label to a tab page

tabMain.TabPages[0].Controls.Add(aLabel);

and get an error "specified argument was out of the range
of valid values.

Any ideas???
 
Yes - I actually have two tab pages - I've also tried
TabPages[1] - which gives the same error.

-----Original Message-----
Hi Liz,

Are you sure that there is TabPages[0]?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

I am trying to add a label to a tab page

tabMain.TabPages[0].Controls.Add(aLabel);

and get an error "specified argument was out of the range
of valid values.

Any ideas???


.
 
There must be something wrong with your tab pages
I just did
this.tabCustomers.TabPages[0].Controls.Add(new TextBox())
On one of my old applications and it worked perfectly. The tabControl (tabCustomers) was built through the designer
Have you gone through debugger to check the pages are actually in the tab when you reference them?
 
I get the same error when I access the page that doesn't exist.
Try this:
Console.WriteLine(tabControl1.TabPages.Count);


--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Liz said:
Yes - I actually have two tab pages - I've also tried
TabPages[1] - which gives the same error.

-----Original Message-----
Hi Liz,

Are you sure that there is TabPages[0]?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

I am trying to add a label to a tab page

tabMain.TabPages[0].Controls.Add(aLabel);

and get an error "specified argument was out of the range
of valid values.

Any ideas???


.
 
I just tried it again with this. infront, ie
this.tabMain.TabPages[0].Controls.Add(aLabel);
and it worked!!!! Don't know why?? Thanks for your help
-----Original Message-----
There must be something wrong with your tab pages.
I just did:
this.tabCustomers.TabPages[0].Controls.Add(new TextBox());
On one of my old applications and it worked perfectly.
The tabControl (tabCustomers) was built through the
designer.
Have you gone through debugger to check the pages are
actually in the tab when you reference them?
 
Back
Top