To start with, there is no such event,
cboNumeClient_SelectedIndexChanged
. It can be you
handler which is added to an invocation list of the event instance
SelectedIndexChanged
of some combo box, but this is not apparent from your code. You also should show where the handle is added via the '+=' operator. As you did not complain that nothing happens on combo box selection, I assume the handler is added properly.
Now, no matter what discrepancy in ID you have, it is not apparent that your handler code does right thing, at least, it is not written in a methodically right way. You should do something like this:
CboNumeClientSelectedIndexChangedHandler(object sender, EventArgs e) {
ComboBox comboBox = (ComboBox)sender;
}
Note that I also renamed you handler, to avoid the violation of Microsoft naming conventions always caused by that auto-generated code. Yes, you are supposed to rename all auto-generated names, but the reason I just explained, and also to give everything semantic names.
Now, even that is not a best approach. When you use a combo box, its list elements could be any objects. I think you are using just strings. This is bad, because then you have to extract some data from a string, which is at least bad for maintenance, and can be unreliable. The civilized approach is this: you create some data type, class or struct with all information you really need for your functionality. The only problem will be: what string will be shown in UI for each element? The answer is: whatever
ToString
returns. So, you also need to override
ToString
for your struct/class representing a combo box list item. Same technique can be used for list boxes, etc.
—SA