views:

556

answers:

1

Scenario

I am using the latest version of DevExpress XtraGrid. I am currently binding the DataView of a DataTable to the datasource of the gridcontrol in C#. Since this DataTable gets updated every second, I have to refresh the gridcontrol.

ALSO

The DevExpress XtraGrid comes with the ability to automatically drag and drop the column headers into a group/sort like manner. This refresh problem I am having is particularly noticeable when I incorporate the use of the "group by column header" feature - In that the data that is grouped is collapsed under a single row. If I expand this row to see the data, it immediately shuts again upon Update - which at the minute is every second, rendering the grouping feature useless.

Question

How can I go about doing this without redrawing the whole thing? I literally just want to see the numbers dynamically changing AND be able to use the grouping feature continually without it collapsing by itself when the rows of data update.

Current Code

        DataView dvw = latestCurve.Tables[0].DefaultView;
        dvw.Sort = "Ccy Asc AND Date Asc";
        this.gridControl2.DataSource = dvw;
A: 

Assuming your default view for gridControl2 is named gridView2:

gridView2.BeginUpdate();
try
{
    your code goes here
}
finally
{
    gridView2.EndUpdate();
}
Kevin Clark