I would like to know how to implement in my combobox
a Messagebox
when selecting an item from the list?
Example:
Combo List:
When you select Mary, a message box will appear stating: You have selected "Mary", OK button.
I would like to know how to implement in my combobox
a Messagebox
when selecting an item from the list?
Example:
Combo List:
When you select Mary, a message box will appear stating: You have selected "Mary", OK button.
The ComboBox
has a SelectedIndexChanged
event, you simply implement it and add MessageBox
to show the desired message.
Something like
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show($"Você selecionou o item {(sender as ComboBox).Text}");
}
To add the event to your component. In the design mode of your form, select the component, right-click on it, and then on Properties . In the Properties window, click the Events icon (lightning) in the Behavior category, double click on the event you want to create for component, in this case the event SelectedIndexChanged