I have a custom combobox as below
public class ListViewCombo : ComboBox
{
ToolStripControlHost listViewHost;
ToolStripDropDown dropDown;
public ListViewCombo()
{
ListView lstView = new ListView();
lstView.BorderStyle = BorderStyle.None;
listViewHost = new ToolStripControlHost(lstView);
dropDown = new ToolStripDropDown();
dropDown.Items.Add(listViewHost);
}
public ListView TListView
{
get { return listViewHost.Control as ListView; }
}
private void ShowDropDown()
{
if (dropDown != null)
{
listViewHost.Width = DropDownWidth;
listViewHost.Height = DropDownHeight;
dropDown.Show(this,new Point(this.Loation.X, this.Height),ToolStripDropDownDirection.BelowRight);
}
}
private const int WM_USER = 0x0400,
WM_REFLECT = WM_USER + 0x1C00,
WM_COMMAND = 0x0111,
CBN_DROPDOWN = 7;
public static int HIWORD(int n)
{
return (n >> 16) & 0xffff;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == (WM_REFLECT + WM_COMMAND))
{
if (HIWORD((int)m.WParam) == CBN_DROPDOWN)
{
ShowDropDown();
return;
}
}
base.WndProc(ref m);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (dropDown != null)
{
dropDown.Dispose();
dropDown = null;
}
}
base.Dispose(disposing);
}
}
}
Every thing is good except when I move the form towards right or left of the screen to partially hide the custom combobox and clicks the dropdown button, then the dropdown automatically adjusts the location and fully displayed. That is even if the combobox is not displayed completely in the screen, the dropdownlist completely displayed by adjusting its position.
Is the ToolStripDropDown has no bounds constrain?.