I use the virtual mode with my UltraGrid. When a new data record is added to my own data source and I increase UltraDataSource row count by one. Event InitializeRow of UltraGrid is always fired on the last grid row. For example, if a newly added data record is displayed on the top, the InitializeRow event is always fired on the first added data record, since it is tired to the bottom grid row.
If I need to setup row level appearances, I have go through all the grid rows. Is there a way to get around with this issue?
Thanks,
Shaolin
Hi Shaolin,
I apologize, testing it again, if you are not using the Insert method, you should be using grid.Rows.Refresh(RefreshRow.FireInitializeRow), if you want the InitializeRow to fire, but it will file for all rows. If you use just the Insert method it will only fire for the row you are inserting.
Michael GermannSoftware Development Team LeadInfragistics
Hi Mike,
The following two lines did not cause InitializeRow event to fire:
UltraDataSourceObject.ResetCachedValues()UltraGridObject.Rows.Refresh(RefreshRow.RefreshDisplay)
How do I know if an UltraGridRow is initialized? Does UltraGridObject.Rows have all UltraGridRow objects including initialized? Can I set Appearance to an uninitialized UltraGridRow?
If you are adding the rows to the top, then unfortunately you will need to have refire the InitializeRow event for every row that moved at the least, likely for each row that is re-painted. Mostly because the indexes for all of them will change. Since you are bound to an UltraDataSource, if you know where positionally the new row will be in your DataSource, if you call UltraDataSourceObject.Rows.Insert(index, false) that should be all you would need.
If you don't have that information, or would rather not go that route, you can use the UltraDataSourceObject.Rows.SetCount(newCount) but you will also need the following:UltraDataSourceObject.ResetCachedValues()UltraGridObject.Rows.Refresh(RefreshRow.RefreshDisplay)
I believe the first approach will be more performant though. Let me know which way works best for you,
Hi Michael,
I need to setup appearance for each row. So whenever data are changed, I have to set appearance for each row. It is not a right way to set appearance for each row using Event InitializeRow. Can you suggest a way to do it please? I am using virtual mode and have thousands of rows, so performance is very important.
Sionce you are just setting the count up, the UltraGrid only sees that a new row was added to the end because from what you are describing the only notification you gave the grid was via the middle tier DataSource setting it's RowCount to up one, via the SetCount method, so the behavior you are getting is expected. If you think that is not what is happening, would you be able to mock up a sample that demonstrates the behavior that you are describing?