Sorry for the duplicate post I did not know there was a forum specifically for the Ultragrid.
I seem to be running into some type of threading issue, it might be a race condition or something similiar. I have an Ultragrid with a bunch of rows. I filter the rows using one of the columns and then I perform some action. I then call the Ultragrid.Rows.Refresh(RefreshRow.ReloadData) method and my GUI becomes unresponsive. So my question is, is there someway to determine when the call to Ultragrid.Rows.Refresh is complete? This method does not have a return value so I was wondering if there was some other way to determine when the Refresh is complete. Also I was wondering if the Refresh is performed on the main HMI thread.
I am running Windows 7 and have Infragistics 10 installed on my machine.
tronoski said: I have a question about the way that we are creating the DataSource for the grid. We are using a BindingSource object as the DataSource for the grid. Here are the steps we take to bind the grid: - BindingSource object is created - BindingSource.DataSource property is assigned to typeof(CustomCollection object) - grid.DataSource is assigned to BindingSource object Is this a proper way to create a DataSource for an Ultragrid?
I have a question about the way that we are creating the DataSource for the grid. We are using a BindingSource object as the DataSource for the grid. Here are the steps we take to bind the grid:
- BindingSource object is created
- BindingSource.DataSource property is assigned to typeof(CustomCollection object)
- grid.DataSource is assigned to BindingSource object
Is this a proper way to create a DataSource for an Ultragrid?
I don't see anything wrong with doing it this way. So yes, this seems like a proper way to do things.
tronoski said: - We also create a Global CustomCollection object (mCCObj), This object contains all of the records that are displayed in the grid. Anytime a new record needs to be added to the grid, it is added to the mCCObj and a call is made to refresh the grid by calling: grid.Rows.Refresh(ReloadData) grid.DisplayLayout.RefreshFilters Is this a proper way to refresh the data in the grid? When these 2 calls are made together our GUI freezes up. If I take out either of the calls, the HMI does not freeze.
- We also create a Global CustomCollection object (mCCObj), This object contains all of the records that are displayed in the grid. Anytime a new record needs to be added to the grid, it is added to the mCCObj and a call is made to refresh the grid by calling:
grid.Rows.Refresh(ReloadData)
grid.DisplayLayout.RefreshFilters
Is this a proper way to refresh the data in the grid? When these 2 calls are made together our GUI freezes up. If I take out either of the calls, the HMI does not freeze.
If the grid is not updating automatically when you add or modify the rows in your custom collection, then calling grid.Rows.Refresh(ReloadData) is something you need to do.
But a better way to do things is to bind the grid to a data source that automatically handles the notifications for you. If you have to call Refresh to get the grid to display the changes, it means that your custom collection implement IList, but not IBindingList.
IBindingList is usually a better choice for a data source. It's a more robust interface which is intended for use in DataBinding.
Having said that, there's nothing wrong with using IList and refreshing the grid manually.
The call to grid.Update seems to update the grid only when modifications to an existing row is made. So my problem has not been solved. Let me give you some more information on the grid and the code I am using. The grid is Read-Only. The user can not "in-line" edit any rows in the grid. All updates made to the grid are done programatically. The user can select a row and choose to edit the contents by clicking a button that will bring up another GUI where edits are made. The modified records is then updated in the CustomCollection that is used as the datasource to the grid. This same GUI is used to add a new record to the grid. Again, a new row is added to the CustomCollection and that is how it is shown in the Grid.
Hi,
tronoski said:- This issue only occurs when I filter on 1 particular column in the grid. If I filter on any other column in the grid, the GUI does NOT become unresponsive.
What is unusual about the column? What's the DataType?
tronoski said:Which leads to my question of, was there any major upgrades to the Ultragrid when going from version 8 to version 10.
In two years, of course there were many changes made to the grid. We added new features and fixed bugs.
tronoski said:As far as the Custom Collection that we used as the Data Source, is this a correct implementation for the DataSource? Do we need to implement any other interfaces?
The grid will work with any object that implements IList or IBindingList. In your case, your data source is apparently using IList. IList is fine, but it's not really the best interface to use. IList is not designed for DataBinding, and there will be some limitation. For example, IList does not send a notification when something in the data changes. IBindingList does this, so if you were using IBindingList, then your calls to Refresh.
tronoski said:Also, the 2 calls we make to refresh the grid after the custom collection is updated, is that the proper way to refresh the grid?
grid.Rows.Refresh(ReloadData) is correct. Refreshing the Filters is up to you, but I assume you have filtering applied and since the filters are not automatically re-applied when you refresh, you need to refresh the filters, too.
tronoski said:I replaced the call to grid.Rows.Refresh(RefreshRow.ReloadData with a call to grid.Update() and my problem went away. What is the difference between these 2 method calls?
These methods do two completely different things. Refresh(ReloadData) tells the grid to re-load the data from the DataSource. This is a method that is specific to the grid.
Update is not specific to the grid. This is a method on System.Windows.Forms.Control. All it does it repaint any invalidated areas of a control. So in this case, it should essentially do nothing. I'm not surprised that the freezing no longer occurs when you call Update instead of Refresh. But I would be surprised if calling Update does what you want, which is to make the grid show changes that occurred in the data source.
I replaced the call to grid.Rows.Refresh(RefreshRow.ReloadData with a call to grid.Update() and my problem went away. What is the difference between these 2 method calls?
Sorry, I forgot to ask the following questions in my previous post. As far as the Custom Collection that we used as the Data Source, is this a correct implementation for the DataSource? Do we need to implement any other interfaces? Also, the 2 calls we make to refresh the grid after the custom collection is updated, is that the proper way to refresh the grid?