I typically just set a BindingList(of T) as the DataSource property on my grid. Sometimes, I want to display this in inverse order. For example, if I have a BindingList(of NewsFeedItems), I'd like the newest items to be at the top. I can always do Insert(0) on my list, but that makes the code less legible and could be inefficient.
Is there a property that would reverse the order my rows are displayed in the grid - in a first shall be last, last shall be first kind of way?
Thanks!
Hello Jeffrey,
Thank you for your feedback and for sharing this with us. We believe that the other community members could benefit from such threads.
Please feel free to let me know if a question about our toolset comes up on your mind.
Sorry for the late response. The solution given almost works for me, but it would really work best if this was a property.
Since I want the order of the rows to be reversed with respect to the data source all the time, I'd rather not have to call some code to do it. Especially since calling it a second time has the side-effect or reversing the rows back to their original order.
Let's say I have this data: {1, 2, 3, 4}After calling the function to reverse I have {4, 3, 2, 1}Now I add another value {4, 3, 2, 1, 5}And call the function to reverse in IntializeRow {5, 1, 2, 3, 4}Oops!
I thought about simply doing this in the IntializeRow event, UltraGrid1.Rows.Move(e.Row, 0)but that didn't work so well either. For example, running code like UltraGrid1.DisplayLayout.Rows.Refresh(RefreshRow.ReloadData)resets the order.
UltraGrid1.Rows.Move(e.Row, 0)
UltraGrid1.DisplayLayout.Rows.Refresh(RefreshRow.ReloadData)
However, if I change the code in the InitializeRow event to If Not e.ReInitialize Then UltraGrid1.Rows.Move(e.Row, 0)I get pretty good results. Still not perfect, but workable.
If Not e.ReInitialize Then UltraGrid1.Rows.Move(e.Row, 0)
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
Could you please review the sample attached to this post and see if it meets your requirements.Please feel free to let me know if I misunderstood you or if you have any other questions.