如何使ComboBox的下拉框足够宽以显示项中所有的字符?

内容纲要

我们可以通过设置ComboBox的DropDownWidth来实现。

代码:

string s = "this is a really, really, really, really, really, long string";

Graphics g = Graphics.FromHwnd(this.Handle);

SizeF size = g.MeasureString(s, comboBox1.Font);

comboBox1.DropDownWidth = Convert.ToInt32(size.Width);

this.comboBox1.Items.Add(s);

我的回答: 最多上传一张图片和一个附件
个人中心
今日签到
私信列表
搜索