写了一个combobox继承类GridCombobox,实现了在下拉列表中加了一个DataGridView,如下:
class GridCombobox:ComboBox
{
ToolStripControlHost GriddataHost;
ToolStripDropDown dropDown; public GridCombobox()
{
DataGridView dataGrid = new DataGridView();
GriddataHost = new ToolStripControlHost(dataGrid);
dropDown = new ToolStripDropDown();
dropDown.Items.Add(GriddataHost);
}
public DataGridView DataGridView
{
get { return GriddataHost.Control as DataGridView; }
}
private void ShowDropDown()
{
if (dropDown != null)
{
GriddataHost.Size = new Size(DropDownWidth-10, DropDownHeight+10);
dropDown.Show(this, 0, this.Height);
}
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONDBLCLK || m.Msg == WM_LBUTTONDOWN)
{
ShowDropDown();
return;
}
base.WndProc(ref m);
}
}
//请问怎么修改弹出下拉的宽度呢???
class GridCombobox:ComboBox
{
ToolStripControlHost GriddataHost;
ToolStripDropDown dropDown; public GridCombobox()
{
DataGridView dataGrid = new DataGridView();
GriddataHost = new ToolStripControlHost(dataGrid);
dropDown = new ToolStripDropDown();
dropDown.Items.Add(GriddataHost);
}
public DataGridView DataGridView
{
get { return GriddataHost.Control as DataGridView; }
}
private void ShowDropDown()
{
if (dropDown != null)
{
GriddataHost.Size = new Size(DropDownWidth-10, DropDownHeight+10);
dropDown.Show(this, 0, this.Height);
}
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONDBLCLK || m.Msg == WM_LBUTTONDOWN)
{
ShowDropDown();
return;
}
base.WndProc(ref m);
}
}
//请问怎么修改弹出下拉的宽度呢???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货