Is it any possible to get my listbox to be shown outside of the form's bounds?
One of the solutions is to make the form itself transparent, and add the panel instead of the form for the background.
But is there any other, more delightful way to do that?
UPD: i need to make a custom autocomplete for textbox, to support wildcards. so i want a listbox to be shown below the textbox. my form's size should be about the size of the textbox. so, stretching the form vertically doesn't work in this case.
thx
Actually, its possible. Here's the way:
public class PopupWindow : System.Windows.Forms.ToolStripDropDown
{
private System.Windows.Forms.Control _content;
private System.Windows.Forms.ToolStripControlHost _host;
public PopupWindow(System.Windows.Forms.Control content)
{
//Basic setup...
this.AutoSize = false;
this.DoubleBuffered = true;
this.ResizeRedraw = true;
this._content = content;
this._host = new System.Windows.Forms.ToolStripControlHost(content);
//Positioning and Sizing
this.MinimumSize = content.MinimumSize;
this.MaximumSize = content.Size;
this.Size = content.Size;
content.Location = Point.Empty;
//Add the host to the list
this.Items.Add(this._host);
}
}
popup = new PopupWindow(listbox1);
PopupWindow.show();
Could you use a second form that only contains the listbox? You'd need a little code to move it relative to the main form, but it should work...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With