glopezz
asked on
How to keep sort state on datagrid after refresh
Hi Experts!
I am using a Windows Forms datagrid, that shows data that is brought from a remote Web Service in xml, then converted to a dataset. Once I have the dataset, I use one of the tables as my datagrid's data source.
The process of bringing the data occurs every 5 seconds, so I fetch the data and refresh the datagrid every 5 seconds using a timer to get the data displayed.
This is what happens every 5 seconds:
1- Get xml from web service
2- Convert xml into dataset
3- Use one of the dataset's tables as the datagrid datasource (DataGrid1.DataSource = dataSet1.Tables(0)
4- Refresh the datagrid (DataGrid1.refresh)
The problem is that I need the current sorting to be kept even after the new data is feteched and the data grid is refreshed. I also lose the selected row. Is there a way to keep the data sorted after refreshing the grid? Keeping the current selected row would be very useful too.
Thanks!!
glopezz
I am using a Windows Forms datagrid, that shows data that is brought from a remote Web Service in xml, then converted to a dataset. Once I have the dataset, I use one of the tables as my datagrid's data source.
The process of bringing the data occurs every 5 seconds, so I fetch the data and refresh the datagrid every 5 seconds using a timer to get the data displayed.
This is what happens every 5 seconds:
1- Get xml from web service
2- Convert xml into dataset
3- Use one of the dataset's tables as the datagrid datasource (DataGrid1.DataSource = dataSet1.Tables(0)
4- Refresh the datagrid (DataGrid1.refresh)
The problem is that I need the current sorting to be kept even after the new data is feteched and the data grid is refreshed. I also lose the selected row. Is there a way to keep the data sorted after refreshing the grid? Keeping the current selected row would be very useful too.
Thanks!!
glopezz
I have an idea, but firstly how are you sorting your datagrid?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks willbdman, I am testing this right now. How about the current sort? Is it possible to maintain it?
Thanks
Thanks
ASKER
OK, saving the row sub works fine, however although the small "arrow" of the selected index is positioned where it shoud, the entire row is not "highlighted" as it was originally. Is there a way to highlight it?
Thanks
Thanks
I'm not sure with that one....
only thin i could think of would be to change the selection background colour:-
Me.DataGrid1.SelectionBack Color = Color.Blue
however, this would cause problems with other selected rows.
only thin i could think of would be to change the selection background colour:-
Me.DataGrid1.SelectionBack
however, this would cause problems with other selected rows.
What about the answer I gave?
He uses the first answer I Gave