(Windows application)
I have created a KeyDown event for my comboboxes, which looks like this:
findRecords simply redraws part of the screen.
It is intended so the user can use the arrow keys to navigate up and down the combobox and then use the neter key to make their selection.
When the selection is made and the enter key pressed, the screen redraws itself (i.e. calls the findRecords() method) fine on the first time I try it, but after that it draws itself more than once. I think that on the second time it is 2, then 4 then 8 etc.
I wondered if that was because of the way I had appended the event handler:
but the comboBoxes aren't redrawn every time the screen is redrawn anyway.
I'm sorry if I haven't explained this very well, but any help would be appreciated.
I have created a KeyDown event for my comboboxes, which looks like this:
Code:
protected void comboBox_KeyDown(object sender, KeyEventArgs e)
{
ComboBox cbSender = (ComboBox)sender;
if (e.KeyValue == 13)
{
findRecords();
}
}
It is intended so the user can use the arrow keys to navigate up and down the combobox and then use the neter key to make their selection.
When the selection is made and the enter key pressed, the screen redraws itself (i.e. calls the findRecords() method) fine on the first time I try it, but after that it draws itself more than once. I think that on the second time it is 2, then 4 then 8 etc.
I wondered if that was because of the way I had appended the event handler:
Code:
if (this.Controls[i] is ComboBox && isPageLoad)
{
this.Controls[i].KeyDown += new KeyEventHandler(this.comboBox_KeyDown);
}
I'm sorry if I haven't explained this very well, but any help would be appreciated.