Home All Groups Group Topic Archive Search About

Adding Controls At Run-Time [Win #C]

Author
18 May 2006 3:08 PM
MikeY
Hi everyone,

I have built a user control "keyboard" and I am trying to figure a way to
add this control at run-time. I have also tried creating a Inherited user
control, which I am able to add this to my form at run-time, but does not
have the functionality of passing the data back to the main form, ie: data
from the keys being pressed (delegate) or being able to close this control
and getting rid of it after it is no longer needed.

my Code that I've been working with is as follows:

HOST.I_Ctrl_KeyBoard myKeyBoard= new HOST.I_Ctrl_KeyBoard();
myKeyBoard.Location = new System.Drawing.Point(275, 305);

myKeyBoard.Parent = this;
myKeyBoard.BringToFront();
myKeyBoard.Show();

Does anyone have a sample syntax or suggestions, tips, links, etc. Anything
is appreciated.

Thanks,

MikeY

Author
18 May 2006 5:10 PM
Kevin Spencer
You need to add the Control to the Controls Collection of whatever Control
you want to host it in, even if that is just the Form itself.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.

Show quoteHide quote
"MikeY" <mikesi***@yaho.com> wrote in message
news:360bg.8819$aa4.290197@news20.bellglobal.com...
> Hi everyone,
>
> I have built a user control "keyboard" and I am trying to figure a way to
> add this control at run-time. I have also tried creating a Inherited user
> control, which I am able to add this to my form at run-time, but does not
> have the functionality of passing the data back to the main form, ie: data
> from the keys being pressed (delegate) or being able to close this control
> and getting rid of it after it is no longer needed.
>
> my Code that I've been working with is as follows:
>
> HOST.I_Ctrl_KeyBoard myKeyBoard= new HOST.I_Ctrl_KeyBoard();
> myKeyBoard.Location = new System.Drawing.Point(275, 305);
>
> myKeyBoard.Parent = this;
> myKeyBoard.BringToFront();
> myKeyBoard.Show();
>
> Does anyone have a sample syntax or suggestions, tips, links, etc.
> Anything is appreciated.
>
> Thanks,
>
> MikeY
>
Are all your drivers up to date? click for free checkup

Author
18 May 2006 5:12 PM
PIEBALD
> HOST.I_Ctrl_KeyBoard myKeyBoard= new HOST.I_Ctrl_KeyBoard();
> myKeyBoard.Location = new System.Drawing.Point(275, 305);
>
> myKeyBoard.Parent = this;
> myKeyBoard.BringToFront();
> myKeyBoard.Show();
>

If this is to be a control on the form you need:
this.Controls.Add ( myKeyBoard) ;



Post Thread options