Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset question

Status
Not open for further replies.

Smitty020

MIS
Jun 1, 2001
152
US
I have a combobox that is loaded with the Clientname from a dataset. Also on the form, I have a label, in which I would like to display the clientid. I would like to have this id change whenever someone selects a new client. Is this possible?

Thanks for your help!

Smitty
 
Implement public event EventHandler SelectedIndexChanged;
This can be useful when you need to display information in other controls based on the current selection in the ComboBox. You can use the event handler for this event to load the information in the other controls.

-obislavu-

 
I was saying to implement a handler to process the SelectedIndexChanged event:
cbx.SelectedIndexChanged+=OnSelectedIndexChanged;

private void OnSelectedIndexChanged(object sender, System.EventArgs e)
{
//
}
-obislavu-
 
I am quite new at this. I think I see what you are saying. Would it be pissible for you to give a small example.

Thanks!
-Smitty
 
If you are using VS, just doubleclick on the comboBox.

VS then creates the code needed to link things up and creates a routine "comboBox1_SelectedIndexChanged"that you'll need to edit to carry out the modifications to the form that you need. Otherwise, you'll need to manually add the changes obislavu talked about above.

SelectedIndexChanged is the default event. If you want to access other events, you can do so through by viewing the properties of the combobox. If you click on the events button on the properites form (a little lightning bolt) it will show you all the events that you can access....Doubleclicking any one will do the same process as above.

d-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top