Open Forms in a TabControl (C#)

  • Thread starter Thread starter Soren-a
  • Start date Start date
S

Soren-a

Hi

I am writing a program for windows CE in C#.NET. The programs user
interface consists of a TabControl with 6 tabs. Each tab is to hold a
number of panels, each with a number of button and textfields.

To avoid having too many controls in one Form (and exceeding
"Initialize Components"'s 64kb), I was planing to make the "Main form"
with an empty TabControl with the 6 tabs, and each of the tab's panels
on 6 seperate forms, and then load the correct form into the correct
tab when it is selected.

My questions is now:

1) Is it possible to do it this way?

2) If it is, how do I do it?

Any help will be much appriciated!!

Thanks in advance.

Regards
Søren Augustesen
 
It should be possible. First try setting the sub-form's Parent to the
TabPage. If that fails, then get the TabPages's hWnd and the sub-form's
hWnd and P/Invoke to set the parent.

-Chris
 
Hi Chris

Thanks for the reply.

I'm quite new to .NET programming, and I wonder if you could give a
bit more detail on how to do this.

Also what is "hWnd"?

Regards
Søren Augustesen
 
have you tried something like this:

MyForm myform = new MyForm();
myform.Parent = TheTabPage;

and maybe:
myform.Top = 0;
myform.Left = 0;
myform.Height = TheTabPage.Height;
myform.Width = TheTabPage.Width;

(that is was he meant by setting the parent)

"hWnd" is the "handle of the window (form)" and it's a common term used in
the Windows API (you need to P/Invoke some core Window-API to set the
Parent of a window at "low level".. not very nice for a .NET app and no, i
cannot tell you which DLL you would need etc. :-) )

Boris
 
Back
Top