I'm working on a WinForms app. My ComboBox
has DropDownClosed
event, but I need to fire this event from a Button
. How can I do this?
Asked
Active
Viewed 294 times
2

Salah Akbari
- 39,330
- 10
- 79
- 109

Aidin
- 29
- 4
-
Duplicate -> http://stackoverflow.com/questions/12184614/trigger-controls-event-programmatically – Aimnox Jun 02 '16 at 07:49
-
Most of the answers here have function invoke solution and it's probably fine for you but they not answers the question "how to fire event from code". – Logman Jun 02 '16 at 12:13
2 Answers
2
Like this:
private void button1_Click(object sender, EventArgs e)
{
comboBox1_DropDownClosed(sender, e);
}
private void comboBox1_DropDownClosed(object sender, EventArgs e)
{
MessageBox.Show("Test");
}

Salah Akbari
- 39,330
- 10
- 79
- 109
-
If I want to fire DropDownClosed from within form_load, how can I do this? – Aidin Jun 02 '16 at 07:57
-
@Aidin...In same way. Just call the `comboBox1_DropDownClosed(sender, e);` in your `form_load`. Like this: `private void Form1_Load(object sender, EventArgs e) { comboBox1_DropDownClosed(sender, e); }` – Salah Akbari Jun 02 '16 at 07:58
1
Please take a look , I believe this is what you are talking about
private void abc_Click(object sender, RoutedEventArgs args)
{
}
private void xyz_Click(object sender, RoutedEventArgs args)
{
abc_Click(sender, args);
}

KhawajaAtteeq
- 401
- 3
- 6