none
How to refresh ListBOx after Update

    Question


  • 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

    Monday, March 24, 2008 5:30 AM

All replies

  • Reassigning the DataSource property of the ListBox should work ok if your using normal DataBinding techniques.

    Monday, March 24, 2008 5:45 AM
  • hello  Dextar

     

    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...

    Monday, March 24, 2008 6:21 AM

  • 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.
    Monday, March 24, 2008 9:38 AM
  • Got the issue solved in my project but still want to learn data bind to list box



    Friday, March 28, 2008 6:49 AM
  • What do you want to learn about data bind to ListBox? Just how to bind or something else?

    Friday, March 28, 2008 7:52 AM

  • 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
    Wednesday, April 02, 2008 4:20 AM
  • 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
    
    Wednesday, August 04, 2010 8:16 PM