Hi. I'm wondering if the grid can be set up to automatically resort based on any current sort selections after new data is entered. Or, does it have to be done manually each time?
Thanks.
Just to clarify, the answer to your question is no - there's no way to make the grid do this automatically. The idea is that it might be pretty jarring to a user to edit a field in the grid and then have the row they were editing suddenly move to a new position when they tab out of the cell or click somewhere else.
So this way we give you, the developer, total control over when the re-sorting takes place.
Also.... there is a RefreshSort method on the row that will move the row to it's new proper place without re-sorting everything. This is more efficient, assuming everything is in the grid is already sorted properly.
hey Mike, i know this is an old post but i'm hoping you can elaborate further on the RefreshSort method but only on the particular row. I think there is a rowchanged event but cannot find it. definitely don't want to resort everything. want to show realtime updates in original sort.
thanks
Al
Thanks for responding Mike. that's exactly what i ended up doing.
listening for ListChanged/PropertyChanged on the BindingSource then grabbing the value and finding that value in the grid by LINQ/primary key.
This is that event handler
void bSource_ListChanged (object sender, ListChangedEventArgs e) { int irow = -1; try { var obj = bSource[e.NewIndex]; List<Infragistics.Win.UltraWinGrid.UltraGridRow> findRow = (from x in gridRTUpdate.Rows where x.Cells["TradeID"].Value.ToString() == ((AimTrade)obj).TradeID select x).ToList(); if (findRow.Count > 0) { irow = findRow[0].Index; gridRTUpdate.Rows[irow].Appearance = new Infragistics.Win.Appearance() { BackColor = Color.Yellow }; gridRTUpdate.Rows[irow].RefreshSortPosition(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Mike Saltzman"] The most efficient thing to do would be to trap when the data source changes are made and then sort the grid at that point. But there are a couple of challenges here. First, you either have to sort the entire grid, or else find the correct UltraGridRow that corresponds to the data row. If you have a small number of rows, then the first option might actually be more performant, because in order to find the UltraGridRow, you will need to loop through the grid rows and examine the ListObject of the row to see if it's the data source row.
The most efficient thing to do would be to trap when the data source changes are made and then sort the grid at that point. But there are a couple of challenges here.
First, you either have to sort the entire grid, or else find the correct UltraGridRow that corresponds to the data row. If you have a small number of rows, then the first option might actually be more performant, because in order to find the UltraGridRow, you will need to loop through the grid rows and examine the ListObject of the row to see if it's the data source row.
didn't even think about this and have to test. Data comes into the grid via queue so we'll always have the record before it gets updated. Actually Queue->InMemoryCache(Dictionary/BindingList)
Mike Saltzman"] And, just to make things a little more complicated, the grid responds to the DataSource notifications asynchronously. So if you add a row to your data source and then immediately try to find that row in the grid, it won't be there, yet. What you can do is call grid.Update, which will force the grid to paint itself and that will synchronously add the new row.
And, just to make things a little more complicated, the grid responds to the DataSource notifications asynchronously. So if you add a row to your data source and then immediately try to find that row in the grid, it won't be there, yet. What you can do is call grid.Update, which will force the grid to paint itself and that will synchronously add the new row.
thanks again
Hi Al,
If you modify the Data Source, then none of those events will fire. They only fire when you modify data through the grid.
You could use InitializeRow, but I'm not sure if that's a good idea, since this event will fire any time any value in any cell changes, and it could cause a big performance hit.
if it helps, the underlying datasource is a custom BindingList<T>. the grid receives the updates in realtime but column has to be clicked to resort.
another symptom could be none of the grids events have fired for me. AfterCellUpdate or AfterRowUpdate. data is only being modified from the underlying datasource, Not by user entry/edit mode.