Subcontrols

B

Beeeeeves

If I have a project with a component that is derived from a control, say
RichTextBox, I insert this control into a form by placing a standard
RichTextBox on the form, and then doing a find and replace within the code
file of the form, replacing System.Windows.Forms.RichTextBox with the name
of my custom RichTextBox-derived class.
Is this the correct way to do it?

If I then want the RichTextBox to contain another custom control, derived
from, say, a ListBox, I drag a standard ListBox onto the 'virtual'
(peach-colored) designer of the component and do a find and replace again in
the same way, this is because I want all the code to manipulate the custom
ListBox-derived control to be within the code of the RichTextBox-derived
control - but I can't get the ListBox to display* unless its container is
the actual main form itself, which means I have to have the code to
manipulate the custom ListBox-derived control in the form, which I don't
really want. Is there any way I can get the custom RichTextBox-derived
control to completely contain the custom ListBox-derived control?

* when I say it won't display, the Show() method doesn't fire an error, but
it just isn't visible, even if I call BringToFront().

Any ideas?
 
S

Shakir Hussain

Beeves,

I donno whether you have done this?

//add list box to richedit control
RichTextBox.Controls.Add(listBox);

This is the only thing i am able to figure out for not seeing the list box.

Shak.
 
J

John Wood

The toolbox is a bit weird in visual studio if you ask me. I prefer the
toolbox in VB6.

Other than customizing the toolbox and browsing to a built version of the
DLL, and then selecting the class from there, and adding it to your form,
your suggestion is the only other alternative.

In fact, if you're developing an EXE containing such inherited controls, I
think this is the only option.

Adding a usercontrol through the wizard does seem to register it in the
toolbox, but if you later change the name then it will no longer work... so
it's not the best solution.
 
J

John Wood

Sorry wrong thread :) Please ignore.

John Wood said:
The toolbox is a bit weird in visual studio if you ask me. I prefer the
toolbox in VB6.

Other than customizing the toolbox and browsing to a built version of the
DLL, and then selecting the class from there, and adding it to your form,
your suggestion is the only other alternative.

In fact, if you're developing an EXE containing such inherited controls, I
think this is the only option.

Adding a usercontrol through the wizard does seem to register it in the
toolbox, but if you later change the name then it will no longer work... so
it's not the best solution.

again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top