How to Use ComboBox inside ComboDropDown in Windows Forms ComboBox DropDown (ComboDropDown)
9 Dec 2019 / 2 minutes to read
This section deals on how to use two combobox within the dropdown area of a ComboDropDown. The panel contains two ComboBoxes and a Button. The text will change only after the Button had pressed.
The steps are as follows.
- Create the ComboBoxes and OK button.
- Populate the ComboBoxes.
- Add these controls to the Panel.
- Set the PopupControl property of the ComboDropDown to the same Panel.
- To avoid closing the ComboDropDown after selecting the item in ComboBox, handle the SelectedIndexChanged event of both ComboBoxes and keep the DropDown showing.
//Indicates whether the combo box is displaying its drop-down portion.
private void comboBox1_SelectedIndexChanged(object sender,EventArgs e)
{
comboDropDown1.DroppedDown=true;
}
private void comboBox2_SelectedIndexChanged(object sender,EventArgs e)
{
comboDropDown1.DroppedDown=true;
}
'Indicates whether the combo box is displaying its drop-down portion.
Private Sub comboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
comboDropDown1.DroppedDown=True
End Sub
Private Sub comboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
comboDropDown1.DroppedDown=True
End Sub
- In the button click event of the Button inside the panel, insert these codes to close DropDown and to change text of ComboDropDown.
// Closes the dropdown and changes the text.
private void button1_Click(object sender,EventArgs e)
{
comboDropDown.Text=comboBox1.Text+ “ “ + comboBox2.Text;
comboDropDown1.DroppedDown=false;
}
' Closes the dropdown and changes the text.
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
comboDropDown.Text=comboBox1.Text+ " works in" + comboBox2.Text
comboDropDown1.DroppedDown=False
End Sub

Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page