你好社区,
我对 System.Windows.Forms.Combobox-Control 的高度有疑问。我无法改变它。我想用它来编写自己的实现(所有者绘制的自定义控件)。
以下代码对我不起作用(只能尝试)。高度还是21px!
public class TestBox : ComboBox
{
public TestBox()
{
DropDownHeight = 15;
}
protected override Size DefaultSize
{
get
{
return new Size(15,15);
}
}
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
base.SetBoundsCore(x, y, 15, 15, specified);
}
}
请帮帮我。
祝好, 马可
最佳答案
The ComboBox height should be resized based on the font that is assigned to it.
因此,更改组合字体。见another discussion on this subject .
ComboBox 的 MinimumSize
属性编码如下:
public override Size MinimumSize
{
get
{
return base.MinimumSize;
}
set
{
// can see that Height is not taken in consideration - is 0
base.MinimumSize = new Size(value.Width, 0);
}
}
关于c# - 是否可以为 System.Windows.Forms.Combobox-Control 设置小于 21 像素的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2252443/