PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Adding Forms to TabPages

Reply

Adding Forms to TabPages

 
Thread Tools Rate Thread
Old 06-03-2006, 02:09 PM   #1
=?Utf-8?B?QmlsbA==?=
Guest
 
Posts: n/a
Default Adding Forms to TabPages


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

  Reply With Quote
Old 06-03-2006, 02:24 PM   #2
Daniel Moth
Guest
 
Posts: n/a
Default Re: Adding Forms to TabPages

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
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off