
Custom Controls and Constituant Controls
To just answer your question - yes you can just inherit from a base control
and add another control. One way is to add the textbox in design mode and
ensure the designer has generated an InitializeComponent method and is
adding it to the controls collection; if not add it in yourself.
You may have to set the location and use Control.BringToFront to ensure it's
not behind the existing textbox.
Quote:
> In my battles with databinding the stock ComboBox (in DropDown mode), I've
> given myself toward creating a UserControl that incorporates this
> functionality.
> In inheriting, I've got two choices: inherit from ComboBox or inherit from
> UserControl.
> Inheriting from ComboBox SEEMS the best route, since it contains the
> functionality I need. However, I need to add a TextBox and position it
> directly over the text portion of the base ComboBox. I haven't been able
to
> make this work.
> Inheriting from UserControl and adding a ComboBox and a TextBox is an
easier
> approach, as placing the TextBox over the ComboBox is much simpler.
However
> I have to implement the properties of the ComboBox that I want to use, and
> that's a bit of work.
> My question: Can one inherit from a base control (say ComboBox) and add a
> constituent control to be visibly used as part of the new control? Or do
I
> have to go the UserControl route??
> Thanks,
> --- Jim ---