Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When u select a value in list box, all the details correspond to that ID, should display in respected text boxes.
Example:
C#
Emp_ID:       ListBox
Emp_Name:     TextBox
Emp_Add:      TextBox
Emp_email:    TextBox
Emp_PhoneNo:  TextBox

If you select value in listbox, textbox fields should retrieve values automitically from database. Whats the code for that.
Please help me out.
Posted
Updated 8-Nov-12 18:17pm
v2

1 solution

If you're binding your ListBox to say a BindingList, you can use the BindingLists's ListChanged event. The ListChangedEventArgs has an argument ListChangedType which tells you if an item was added, removed, moved or changed.

You can do similar things with similar collections.

If you're adding or removing items yourself, you can obviously directly tell some other piece of code to execute or you can just create and raise an event yourself, provided you have a ListAdded event:

C#
ListAdded(this, new ListAddedEventArgs() { List = myList, Item = myItem });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900