Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added a datagridview to my C# Windows form. I have 4 columns, and a row count of 19. On the same Windows Form, I also have a list box. If an item in the listbox is selected (SelectedIndexChanged), all the info of that item (4 catagories), which is stored in a database table, should be displayed in the 4 different columns of the datagridview. When next item in listbox is selected, that information should be dsplayed in the 4 columns of the datagridview again, but in next available row?

The datagridview is not linked to any datasource.
Posted
Comments
Bala Selvanayagam 3-Oct-11 1:17am    
Your question is not clear....Please improve your question and post it again

In selected index change of the listbox,
get the required data from the database, store it into a DataTable object.
and assign it as a datasource to the listbox,
next time you get the data, just add it to the DataTable object.

For avoiding so many database hits, you may have all the data at once and filter it using a DatView according to the selected value in the list box.

For examples, do a Google/Bing search.
 
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