有没有办法在CF3.5中设置组合框的下拉高度? CF中没有这样的属性,我似乎也无法在设计上做到这一点。感谢任何帮助。谢谢。
// --------------------------------------------- ----------------更新--------------------------------- ------------------------ //
[DllImport("coredll.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[StructLayout(LayoutKind.Sequential)]
struct RECT
{
public int left, top, right, bottom;
}
[StructLayout(LayoutKind.Sequential)]
struct COMBOBOXINFO
{
public int cbSize;
public RECT rcItem;
public RECT rcButton;
public int stateButton;
public IntPtr hwndCombo;
public IntPtr hwndItem;
public IntPtr hwndList;
}
public static IntPtr IntPtrAlloc<T>(T param)
{
IntPtr retval = Marshal.AllocHGlobal(Marshal.SizeOf(param));
Marshal.StructureToPtr(param, retval, false);
return retval;
}
COMBOBOXINFO cbi = new COMBOBOXINFO();
IntPtr cbiPointer = IntPtrAlloc(cbi);
SendMessage(comboBox1.Handle, CB_GETCOMBOBOXINFO, IntPtr.Zero, cbi);
答案 0 :(得分:0)
我自己没试过,但我相信可以做到。 覆盖组合框的OnHandleCreated,使用pinvoke调用带有CB_GETCOMBOBOXINFO(0x0162)的SendMessage,它将返回包含下拉列表控件句柄的Comboboxinfo结构,将句柄存储到下拉列表中。如果要使用下拉列表中的句柄和所需高度更新下拉高度,请将SetWindowPos更新。