Creating an EventHandler that takes a function as a parameter - WHEN THE FUNCTION ITSELF HAS PARAMETERS
Posted on 2006-05-23
I need to implement an EventHandler in C# that takes a function as a parameter - and where the function itself has parameters.
So far, I've found lots of stuff on EventArgs and delegates, but I just haven't been able to quite put this together.
What I have is a combobox that I want to have trigger an event when it is clicked.
System.Windows.Forms.ComboBox comboBox = new ComboBox();
string str = "A specific value"; //How do I pass this as a parameter to comboBoxOutputs_Clicked?
comboBox.Click += new System.EventHandler(comboBoxOutputs_Clicked);
//Here's the function; I want to set the comboBox's text to "A specific value"
private void comboBoxOutputs_Clicked(object sender, System.EventArgs e)
System.Windows.Form.ComboBox comboBox = (ComboBox)sender;
comboBox.Text = <I want the specific value here that can be passed in as a variable>;
I've looked at a lot of stuff on EventArgs and such, but haven't been able to come up with something workable so far.
Thanks in advance,