October 13th, 2010, 09:31 AM
Passing extra parameters on EventHandler
Hi, new to the board so go easy
Ok the problem I have is this.
I have 2 combo boxes on a form that share "almost" the same functionality. What I'm wanting to do is when Im setting up the event handlers is some how tell the event which combo box is being used to I can use the same code for both combo boxes, hopefully by the use of extra parameters as this is a slightly simplified example. If that makes sense.
I have this at the moment
cmbProducts.KeyUp += new KeyEventHandler(keypressed);
what I want is something along the lines of this
cmbProducts.KeyUp += new KeyEventHandler(keypressed, cmbProducts);
cmbProducts2.KeyUp += new KeyEventHandler(keypressed, cmbProducts2);
public void keypressed(object sender, KeyEventArgs e, ComboBox cmbtouse)
do some combobox giggery pokery...
I've spent the last day trawling through the internet now, by the looks of it I need to use some kind of delegate, but im buggered if I can find any straight forward examples.
Could someone *Please* either point me to some resource that will help me or, basically just show me what I need to, I'm fairly sure what I'm needing is relatively simple - I just cant find any examples !!
Any help would be greatly appreciated here guys
Click Here to Expand Forum to Full Width