I'm writing a derived control that is based on a RichTextBox. Within that derived control, I am adding a ListBox. I want the listbox to be able to display outside of the RichTextBox control though, but I'm not sure how to do that.
Currently, I am dynamically creating the ListBox control, and adding it to the RichTextBox with the following code:
ListBox myListBox = new ListBox();
this.Controls.Add(myListBox);
How can I make that ListBox display outside of the RichTextBox if I need it to
Thanks,
Chris

Adding a control to an user control, and allowing it to be visible outside of the parent control
peterxz
Or just outside the RichTextBox control
If just outside the RichTextBox control, then you can add the listbox you dynamically created on the RichTextBox's parent ControlCollection:
ListBox myListBox = new ListBox();
if (this.Parent != null)
{
this.Parent.Controls.Add(myListBox);
myListBox.BringToFront();
}
else
{
this.Controls.Add(myListBox);
}
That way, if your listbox is added to parent's controlCollection, then your RichTextBox can't clip your listbox from display.
-chris
twiggy
NativeWindow will do, as most people working with floating control uses that class. However, you can also achieve the same floating (pop-up) style by deriving a class from Control.
Try the VBAccelerator style, I find it handy and easy to learn (as I used this approach to many of my pop-up controls):
http://www.vbaccelerator.com/home/NET/Code/Controls/Popup_Windows/Floating_Controls/article.asp
The article shows how to create a tool-tip from Control; you can use the same method to pop a listbox to your RichTextBox.
Regards,
-chris
Henry N
clinicalcom
I've found the NativeWindow class, and it looks like what I need to use, but I can't find any good examples of how to use it the way I need to.
This is the best example that I've found, but they don't really explain how the NativeWindow was used.
http://www.thecodeproject.com/cs/miscctrl/BallonToolTips.asp