PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Adding Forms to TabPages
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Adding Forms to TabPages
![]() |
Adding Forms to TabPages |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Ok, so I have a VS2003 CF project that I converted to VS2005 CF v2.0. In the
original version I had a TabControl with TabPages that I would add Forms to as follows and it worked great; MyTestForm myForm = new MyTestForm(); tabPage1.Controls.Add(myForm); In VS2005 the identical code throws an ArgumentException of “Value does not fall within the expected range”. This doesn’t make sense to me since Form derives from Control; it seems that it meets the criteria for adding to a ControlCollection. Another news groupie asked this same question on 12/5/2005 & got a reply to the effect that Microsoft hadn’t planned for you to do that so don’t do it. I was hoping someone out there could provide a more satisfying answer, since it is very convenient to use the amenities of the Form such as the load event. Naturally, I would also like to avoid the overhead of developing a workaround and implementing it if there is a reasonable way to make Forms work. (After all, VS2005 was supposed to save us time… right?) Bill |
|
|
|
#2 |
|
Guest
Posts: n/a
|
You have to use a UserControl instead.
If you think about it, that makes more sense that using a form in a tabcontrol. IMO, the fact that it works in CF v1.0 is either a bug or a relaxation given the absense of the UserControl class in v1.0 Cheers Daniel -- http://www.danielmoth.com/Blog/ "Bill" <Bill@discussions.microsoft.com> wrote in message news:113FBD7C-B168-4C84-B22E-584ED88D0E37@microsoft.com... > Ok, so I have a VS2003 CF project that I converted to VS2005 CF v2.0. In > the > original version I had a TabControl with TabPages that I would add Forms > to > as follows and it worked great; > > MyTestForm myForm = new MyTestForm(); > tabPage1.Controls.Add(myForm); > > In VS2005 the identical code throws an ArgumentException of "Value does > not > fall within the expected range". This doesn't make sense to me since Form > derives from Control; it seems that it meets the criteria for adding to a > ControlCollection. > > Another news groupie asked this same question on 12/5/2005 & got a reply > to > the effect that Microsoft hadn't planned for you to do that so don't do > it. I > was hoping someone out there could provide a more satisfying answer, since > it > is very convenient to use the amenities of the Form such as the load > event. > Naturally, I would also like to avoid the overhead of developing a > workaround > and implementing it if there is a reasonable way to make Forms work. > (After > all, VS2005 was supposed to save us time. right?) > > Bill > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

