首页 > 编程知识 正文

字母c的发音,C语言

时间:2023-05-05 04:01:50 阅读:19022 作者:3296

C#学习笔记(16 )如果ComboBox下拉列表框的宽度自适应下拉列表框中的内容宽度大于下拉列表框的宽度

不能在下拉列表框中显示所有内容

下拉列表框的内容可以在下拉列表框中重新绘制

///summary ///列表项目下拉窗口宽度自适应///summary//param name=' combobox '/paramprivatevoidadjustcomboboxdropdownlox try { comboboxsendercombobox=null; 组合盒体(if )发送器组合盒体=)组合盒体(combobox )组合盒体; else if (comboboxistoolstripcombobox ) sendercombobox=) toolstripcombobox ).combobox; else返回; int width=senderComboBox.Width; g=sender combobox.create graphics (; font=senderComboBox.Font; //checksifascrollbarwillbedisplayed.//if yes, thengetitswidthtoadjustthesizeofthedropdownlist.intvertscrollbarwidth=(sender combobox.items.countsendercombobox.max 新建窗口; foreach (objectsinsendercombobox.items )/loopthroughlistitemsandchecksizeofeachitems.{ if (s!=null () newwidth=(int ) g.measurestring (s.tostring ).Trim ),font ).Width vertScrollBarWidth; 新宽度(if )宽度=新宽度; //setthewidthofthedropdownlisttothewidthofthelargestitem.} sender combobox.drop down width=width; }catch{}finally{if(g!=null(g.dispose ); } privatevoidcombobox1_ drop down (对象发送器,事件e ) adjustcomboboxdropdrownlistwidth (combobox1); }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。