防止下拉面积由Windows窗体ComboBox控件开幕 [英] prevent dropdown area from opening of combobox control in windows forms

查看:126
本文介绍了防止下拉面积由Windows窗体ComboBox控件开幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows窗体的自定义组合框控件。我想实现的功能,其中的一些条件不应该显示的下拉区域,即我需要防止组合框无法打开基于一些条件基础。

I have a custom combo box control in windows forms. I want to achieve a functionality wherein based on some condition the dropdown area should not be displayed i.e. I need to prevent the combo box from opening based on some condition.

,我发现,其中这可以实现链接,但它是完全防止从表示下拉区域。另外,我不能够调整的方法按我的舒适。链路被赋予这里

I found a link where this can be achieved but it is completely preventing the dropdown area from showing. Also i am not able to tweak the method as per my convinience. The link is given here.

推荐答案

只需添加你的病情到如果语句:

Just add your condition to that if statement:

public class CustomComboBox : ComboBox
{
  protected override void WndProc( ref  Message m )
  {
    if(yourCondition && 
       (m.Msg == 0x201 || // WM_LBUTTONDOWN
        m.Msg == 0x203)) // WM_LBUTTONDBLCLK
      return;
    base.WndProc( ref m );
  }
}

这篇关于防止下拉面积由Windows窗体ComboBox控件开幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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