We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Sorting of Gridcontrol

Hi Guys

Thanks a lot for your help with previous issues. A lot of issues have been resolved.

We are preparing a Voucher Data Entry Program and are using the unbound Gridcontrol.

We have defined 19 rows and 5 columns. We wish to sort the grid programmmatically (not thru the user clicking on the column header) when the user has reached the final right most column and moves on to the next row. We plan on doing this in CurrentCellDeactivating event which we are already using for validation(s).

Our requirements are as follows

1. we wish to sort the first 15 rows only.

2. The soring should be done based on what the user has selected thru a combobox in the first column of every row.

Is there any way we can define a range and sort that range only ? (Just thinking out aloud)...

Do we have to implement Icomparer Interface ?

Thanks & Best Regards in Advance


1 Reply

SA Saravanan A Syncfusion Team April 2, 2007 07:50 PM UTC

Hi RH,

You can sort the grid column programatically by using gridControl1.Data.SortByColumn method. For this you can use the CurrentCellActivated event. Here you can check whether the current cell is moving from the last column by using CurrentCell.MoveFromColIndex property.

To prevent some rows being sorted, remove those rows from the grid and the insert it back after sorting.
To sort the combobox column with the display member you need to implement the IComparer interface.
For implementation, please refer to this sample.

Regards,
Saravanan

Loader.
Live Chat Icon For mobile
Up arrow icon