如何在 Windows 窗体 (C#) 中设置列​​表框的确切高度?

Posted

技术标签:

【中文标题】如何在 Windows 窗体 (C#) 中设置列​​表框的确切高度?【英文标题】:How can I set the exact height of a listbox in Windows Forms (C#)? 【发布时间】:2010-11-24 09:26:14 【问题描述】:

我在设置列表框的高度时遇到了一些困难。

这样的代码...

listbox1.Height = some_number;

... 仅适用于某些数字。似乎列表框的高度可能只是其元素高度的乘积。有没有办法“覆盖”这种行为?

【问题讨论】:

【参考方案1】:

试试,

listbox1.IntegralHeight=false;
listbox1.Height=some_int_number;

【讨论】:

【参考方案2】:

首先,设置

listbox1.IntegralHeight = false;

【讨论】:

【参考方案3】:

对于 VBA 代码:

ActiveSheet.Shapes("ListBox1").ScaleWidth some_relate_numb, msoFalse, _     msoScaleFromTopLeft

listbox1.IntegralHeight=false

listbox1.Height=some_int_number

【讨论】:

以上是关于如何在 Windows 窗体 (C#) 中设置列​​表框的确切高度?的主要内容,如果未能解决你的问题,请参考以下文章