NOCARRIER
NOCARRIER

Reputation: 2634

How to show the DropDown list of a ComboBox in WinForms (Telerik)

I'm trying to initiate the drop down list click for a combobox of type MultiColumnComboBox (RadMultiColumnComboBox).

The behavior I'm trying to emulate is when the user clicks the [v] button of the drop down, which shows the actual list.

My control is a Telerik.WinControls.UI.RadMultiColumnComboBox.

I saw a post on the Telerik forums suggesting to do something like this:

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 

Seems like a viable solution, but I'm not sure how this would work on my C# control.

There is also a Win32 hack I found, but this would not pass code review:

// 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);

If anyone is familiar with a WinForms ComboBox and can help me figure out how to kick off the Show Items/Elements/List event (or whatever its called), I'd really appreciate it!

Upvotes: 1

Views: 5758

Answers (2)

checho
checho

Reputation: 3120

If I understand correctly, you want to open the drop down programatically. If this is the case, here is how you can do that:

radMultiColumnComboBox1.MultiColumnComboBoxElement.ShowPopup();

Upvotes: 1

DoomerDGR8
DoomerDGR8

Reputation: 5042

The equivalent c# is:

RadTextBoxItem item = this.radMultiColumnComboBox1.MultiColumnComboBoxElement.Children(2).Children(0).Children(0) as RadTextBoxItem;

if (item != null) {
    item.Click += OnTextBoxItem_Click;
}

Check if it works for you.

Upvotes: 2

Related Questions