Windows Develop Bookmark and Share   
 index > Windows Forms General > UserControl Questions
 

UserControl Questions

I have a usercontrol which is basically an numericupdown and a label control.

I added this control via the add - add user control menu item instead of creating a new dll for the control.

how do I go about using this control in different forms in my application.

I have tried this in one of my forms init and load methods

CustomNumericUpDown myNum =
new CustomNumericUpDown();

myNum.Location = new Point(88, 80);

myNum.Visible = true;

myNum.Invalidate();

myNum.Show();

the control does not show up in the form, what am i missing

Please help

Chinedu  Wednesday, November 30, 2005 3:30 PM
Did you add myNum to your form's control collection?  I dont see that line of code in what you have above.

this.Controls.Add(myNum);

If you've done that and you still cant locate it, set the Text property of your UserControl, then use the spy++ application  (Search | Find Window) [1] to inspect your running form to see if you can see your control parented to the form.


[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_home_page.3a_.spy.2b2b.asp
JFo - MSFT  Wednesday, November 30, 2005 4:26 PM
Did you add myNum to your form's control collection?  I dont see that line of code in what you have above.

this.Controls.Add(myNum);

If you've done that and you still cant locate it, set the Text property of your UserControl, then use the spy++ application  (Search | Find Window) [1] to inspect your running form to see if you can see your control parented to the form.


[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_home_page.3a_.spy.2b2b.asp
JFo - MSFT  Wednesday, November 30, 2005 4:26 PM

You can use google to search for other answers

Custom Search

More Threads

• Custom BorderStyle of Form
• CAPTURING enter AND tab KEY EITHER
• How do I default the current week?
• Drawing the form - eliminating flicker
• Accessing a control from outside the form class (in form.h)
• Menu control to display embeded tab strips.
• when focus of control changes
• Zoom event for picturebox
• mnemonic Underline can't be seen for toolstrip buttons
• MDI Control Box Behavior