I think what I am trying to do should be simple but I can't seem to find the answer
I have an UltraWinGrid with two bands. I am using a BindingSource that uses a Binding List of one object type (Band 0) that has a property that is a BindingList of a second object type(Band 1). I am able to sort the first band records by declaring the sorting rules in the Sort property of the binding source.
But I also need to sort the Band1 objects by a property of that object type. Can I do this in the Grid properties? What is the property I am looking for? This just needs to be a one-time sort. It won't change and the user cannot change the sorting via the UI.
I have looked at implementing a SortableBindingList extension but I just can't help but think there is an easier way to do this.
Can anyone help?
I'm not sure how (or if) you can do this on the BindingList.
In the grid you can sort by setting the SortIndicator property on a column. I would recommend that you do this in the InitializeLayout event of the grid.
This will display a SortIndicator on the column header and unfortunately, there's no property to disable sorting by the user and still sort the data programmatically.
But what you can do is handle the BeforeSortChange event and cancel it. So the code would look like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Bands[1].Columns["column key"].SortIndicator = SortIndicator.Ascending; } private void ultraGrid1_BeforeSortChange(object sender, BeforeSortChangeEventArgs e) { e.Cancel = true; }
Meh. Not very elegant but it works.
Thanks for the help.
JP