Hello,
I currently have a WinGrid using a DataTable as the datasource. The DataTable contains records that I retreived from an SQL server via a Stored Procedure. When I refresh(rebind) the WinGrid after refreshing the DataTable any selections or expanded nodes, etc will be lost and the grid layout is reset.
What is the proper way to preserve the layout, selections, and expanded nodes after refreshing the data in the underlying DataTable. The data is view only in the WinGrid and is refreshed from the SQL Server every minute or so.
Any suggestions would be appreciated.
Matt
If you are binding the grid to a data source that is not sending notifications that data has changed, then you need to call grid.Rows.Refresh(ReloadData) to get the grid to pick up the changes.
I am facing similar problem , I want to reflect the changes in datasource to the grid ,but unless i bind the grid again i don't see the changes.I want to avoid rebinding basically to preserve the layout. is there anyway where i dont ned to rebing and still see grid reflecting changes !
I am binding to LINQ entities, not to a datatable.
What you are trying to achieve can be done by creating a new datatable in memory and then merge that new datatable with the one binded to the grid. Look up datatable.merge. This will not reset the grid.
You should be able to call .Rows.Refresh(RefreshRow.ReloadData); method from the grid. I got this to work smoothly in one project, but having issues with it on another, not sure if it is the enterprise library or the control itself.
Are you sure? I haven't tested this, but I would assume that setting the DataSource on the BindingSource sends a Reset notificaiton which would cause the grid to fire the InitializeLayout event.
I could be wrong. If I am, then once again, there's no event in the grid you can use. Perhaps you could trap some event of the BindingSource itself?