如何使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);

圈主 管理员

热门评论
:
该帖子评论已关闭
图片审查中...
编辑答案: 我的回答: 最多上传一张图片和一个附件
x
x
个人中心
今日签到
有新私信 私信列表
搜索