ComboBox.SelectedIndexChanging?
How can I handle an combobox selected index event before the index changes ? Winforms doesnot provide any sort of ComboBox.SelectedIndexCh开发者_StackOverflow中文版anging event !
Thanks
I achieved it using ComboBox.DropDown
No you didn't. Use the up/down arrow keys to fire the event without using the dropdown.
To use the SelectedIndexChanged event for this, you need a time machine that goes back by less than a microsecond. It's really unclear why you need this but you can probably get one by deriving your own class from ComboBox. Like this:
using System;
using System.Windows.Forms;
class MyComboBox : ComboBox {
protected override void OnSelectedIndexChanged(EventArgs e) {
// Here
//...
base.OnSelectedIndexChanged(e);
}
}
Insert the code at the dots. You could for example raise your own event there.
I achieved it using
ComboBox.DropDown;
Because my aim was to 'do something' before the combobox opens.
精彩评论