内容纲要
我们可以通过设置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);
请先登录!