I have an UltraWinGrid whose DataSource is an UltraDataSource.I created a button on the form whose action is to sort the data in the grid on the Carrier column. I use the following code: With ugOrderList.DisplayLayout.Bands("Orders") .SortedColumns.Add("Carrier", False, False) .SortedColumns.RefreshSort(True) End WithHowever, when the button is clicked nothing happens. The grid does not sort. If I manually click on the Carrier column, it will sort, but it won't sort programatically.What's wrong?
You should not need to call RefreshSort - adding a sorted column implicitly refreshes the sorting. I imagine you probably just did that because it wasn't working.
In what event is this code called? Are there any rows in the grid at the time? Check the grid.Rows.Count. If there are no rows and the rows are getting added later, then you need to sort the column after the rows are added (or call RefreshSort after the rows exist). Rows that are added while the grid is already sorted will not be sorted automatically until you explicitly refresh the sort. This is to prevent rows from jumping around while a user is modifying data.
Thanks Mike for your response. While your answer was not what did the trick, it did lead me to what I was doing wrong.
You asked me to check the Rows.Count. I did. It had 23 rows. But as I was looking through some of the other properties, I noticed that I already had 2 columns in the SortedColumns property from my initial grid setup. It dawned on me that by ADDING another column, I wouldn't get any change in the data. So I did a SortedColumns.Clear first and then did the add, and it worked like a charm.
I could feel the vibes of your spirit. Thanks.