adding component dynamically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a windows forms custom built requiredfieldvalidator. It is a component, not a control, and I would like to add the component to the form dynamically at runtime. I've tried adding it to the components field of the Form with no luck. Anyone else try and do this before and have any ideas? Since it is not a control, Controls.Add does not work.
 
.... create it and use it... if your component has a constructor that takes
an IContainer parameter

myComponent = new myComponent(this.components)
where 'components' is the member variable of the form added by the designer
(private System.ComponentModel.IContainer components;)

....

if your component is a property extender:
myComponent.SetRequired(textBox1, true);


scottkingoh said:
I have a windows forms custom built requiredfieldvalidator. It is a
component, not a control, and I would like to add the component to the form
dynamically at runtime. I've tried adding it to the components field of the
Form with no luck. Anyone else try and do this before and have any ideas?
Since it is not a control, Controls.Add does not work.
 
Back
Top