如何在DataGridView的ComboBox中设置DropDownStyle

编程入门 行业动态 更新时间:2024-10-11 13:26:35
本文介绍了如何在DataGridView的ComboBox中设置DropDownStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在DataGridView控件中的ComboBox中将DropDownStyle设置为DropDown.我想通过在设计时设置此属性来做到这一点;但是,这不是我可以选择的选择.在加载表单时可以这样做,但是我不知道该怎么做(请VB). 谢谢,Eddie

I would like to set the DropDownStyle to DropDown in a ComboBox that is in a DataGridView control. I would like to do this by setting this property at design time; however, it isn''t an option I can pick. Doing it when the form loads would be fine, but I don''t know how to do it (VB, please). Thanks, Eddie

推荐答案

如果您的ComboBox是ComboBoxColumn的一部分,那么Manfred的解决方案可能无法正常工作. 看看此 [ ^ ] MSDN.Social上的线程(向下滚动,直到看到来自"mcassoc"的第一条消息),然后在该消息中记下EditingControlShowing事件的事件处理程序.使用该代码在DataGridView上处理该事件将使您能够实现所需的功能. If your ComboBox is part of a ComboBoxColumn then Manfred''s solution might not work. Take a look at this[^] thread on MSDN.Social (Scroll down until you see the first message from ''mcassoc'') and in that message take note of the event handler for the EditingControlShowing event. Using that code to handle that event on your DataGridView will enable you to achieve what you want.

您可以从表单加载事件或表单构造函数中进行操作: You can do it from your forms load event or in the forms constructor: ... Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDown ...

希望对您有帮助. 最好的问候, 曼弗雷德(Manfred)

Hope that helps you. Best Regards, Manfred

更多推荐

如何在DataGridView的ComboBox中设置DropDownStyle

本文发布于:2023-11-06 08:48:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563223.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   DataGridView   DropDownStyle   ComboBox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!