|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adding Controls At Run-Time [Win #C]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 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. -- Show quoteHide quoteHTH, Kevin Spencer Microsoft MVP Professional Numbskull The man who questions opinions is wise. The man who quarrels with facts is a fool. "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 > > HOST.I_Ctrl_KeyBoard myKeyBoard= new HOST.I_Ctrl_KeyBoard(); If this is to be a control on the form you need:> myKeyBoard.Location = new System.Drawing.Point(275, 305); > > myKeyBoard.Parent = this; > myKeyBoard.BringToFront(); > myKeyBoard.Show(); > this.Controls.Add ( myKeyBoard) ;
Simple Inheritance - An unhandled exception of type 'System.StackOverflowException'...
Checked Listbox? Protected keyword Scheduling within a windows service string to integer array How can I get a bitmap of a Form using .NET 1.1 (ie NO CopyFromScreen) Multithreading in GUI application List all classes in .NET Exception in a Thread other than Main thread Receiving Error eMails... |
|||||||||||||||||||||||