I have a windows form in c# 1.1 , Initially i load a list box with customer name ( A to N ) on selection of a record from the
list box ( 'A' ) i load a datagrid with all the occurance on 'A' ( A1, A2 , A3) there is check box in data grid to select one record and discard other same is updated now after update
Problem :: 1) i want to reload the listbox with records ( B to N ) and not 'A' also i want to clear data grid
Thanks in advance
It is good practice to use Datasource binding to the Listbox than assigning values directly in case of data refresh bcos if u want to refresh the data in lumpsum then if just insert/delete/update the record in Datasource it will autorefresh your UI control. In general direct refreshing an UI control for large data is heavy as compared to datasource updation....
As per your problem..
If you are using direct updation then you have to repeat the process of populating Listbox (as you have done initially) by clearing the previous values to keep you data base data in sinc with Listbox values...Same will be the case in datasource but it will be faster as compared..
if any issue pls let me know...
Thanks for the reply,
Yes i also want to go by your method if you can give a example so as it is easier to understand
as to how to bind the data to list box and keep it synced with data base and the user does not gets the immpresion
as to the list box is reloaded again and again.
I am currently working on windows form( C# 1.1 ) i am using the loop to add mulitiple items to
the list controls i want to know how to use data bindings for the same to add and reload
list controls using binding in windows form
Please correct me if am going wrong
Thanks in advance
Here is an example, though it is written in vb .net the syntaxes should be the same:
It requires that you already have a dataset and know how to add the data to it.
Dim bs As New BindingSource bs.DataSource = DataSetName bs.DataMember = TableNameAsString ListBox.DataSource = bs ListBox.ValueMember = FieldNameAsString