Refreshing DataGrid automatically

Posted on 2009-04-29
Last Modified: 2013-12-17
Good morning,

I would like to update my DataGrid but I do not know the "best way" to do that if there is one.

At the moment, I'm using an ObservableCollection to know when a new data is added to my Collection and then use the event "CollectionChanged" to update manualy my DataGrid.

Is there another way to do that without using an ObservableCollection ? Binding ?

Thank you
Question by:smuhr
    LVL 83

    Accepted Solution

    DataTable. Use a DataTable as the datasource to the datagridview.

    Author Comment

    Why is it better ?

    I would like to understand because I've never used it :)

    Thank you,
    LVL 83

    Expert Comment

    Its better bacause its meant for this type of scenario. Any changes made in the datagrid when a datatable is the datasource would be automatically reflected to the datatable and you can then save these changes to database as well.

    Author Comment

    Ok, thank you :)


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now