如何在DataGridView的ComboBox中设置DropDownStyle [英] How to set DropDownStyle in ComboBox in DataGridView

查看:168
本文介绍了如何在DataGridView的ComboBox中设置DropDownStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

谢谢,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.net, 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆