【问题标题】:How to show the DropDown list of a ComboBox in WinForms (Telerik)如何在 WinForms (Telerik) 中显示组合框的下拉列表
【发布时间】:2011-11-02 17:19:29
【问题描述】:

我正在尝试为 MultiColumnComboBox (RadMultiColumnComboBox) 类型的组合框启动下拉列表单击。

我试图模拟的行为是当用户单击下拉列表的 [v] 按钮时,它显示了实际列表。

我的控件是 Telerik.WinControls.UI.RadMultiColumnComboBox。

我在 Telerik 论坛上看到一个帖子建议做这样的事情:

Dim item As RadTextBoxItem =     TryCast(Me.radMultiColumnComboBox1.MultiColumnComboBoxElement.Children(2).Children(0).Children(0), RadTextBoxItem) 

 If item IsNot Nothing Then 
     AddHandler item.Click, AddressOf OnTextBoxItem_Click 
 End If 

似乎是一个可行的解决方案,但我不确定这将如何在我的 C# 控件上工作。

我还发现了一个 Win32 hack,但这不会通过代码审查:

// Declare the following in your class

[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);
 public const int CB_SHOWDROPDOWN = 0x14F;

 // In the leave event of combobox, use the following code:

  SendMessage(comboBox1.Handle.ToInt32(), CB_SHOWDROPDOWN, 1, IntPtr.Zero);

如果有人熟悉 WinForms ComboBox 并能帮助我弄清楚如何启动 Show Items/Elements/List 事件(或其他任何名称),我将不胜感激!

【问题讨论】:

    标签: c# winforms winapi telerik


    【解决方案1】:

    等价的c#是:

    RadTextBoxItem item = this.radMultiColumnComboBox1.MultiColumnComboBoxElement.Children(2).Children(0).Children(0) as RadTextBoxItem;
    
    if (item != null) {
        item.Click += OnTextBoxItem_Click;
    }
    

    检查它是否适合你。

    【讨论】:

      【解决方案2】:

      如果我理解正确,您想以编程方式打开下拉菜单。如果是这种情况,您可以这样做:

      radMultiColumnComboBox1.MultiColumnComboBoxElement.ShowPopup();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-05-16
        • 1970-01-01
        • 2015-10-01
        • 2011-04-22
        • 1970-01-01
        • 1970-01-01
        • 2011-04-14
        相关资源
        最近更新 更多