Hi,
I'm sure this must be referenced somwhere but I just can't find it...
How can you make it so that when the user clicks a column header in the grid the column sorts and the column is selected - so they might be able to subsequently hide it, etc.
Thanks for any information.
Looks like that's the answer.
Thanks a lot!
Steve
Hi Steve,
My guess is that it doesn't work because the columns in the SortedColumns collection are clones of the real columns that don't actually belong to the grid. So try getting the "real" column and selecting it, like this:
private void ultraGrid1_BeforeSortChange(object sender, BeforeSortChangeEventArgs e) { e.SortedColumns.Band.Columns[e.SortedColumns[0].Key].Header.Selected = true; }
Yes, I've been trying that, but can't get the Selection to work. Using .SortedColumns property of e in BeforeSortChange (AfterSortChange has no obvious way to get to the column that was sorted)
e.SortedColumns[0].Header.Selected = true; //doesn't workthis.ultraGridPlans.Selected.Columns.Add(e.SortedColumns[0].Header); //doesn't work either
Do you know of any code that does?
Thanks
There's no built-in way to do both. What I would do is set the HeaderClickAction to either sort or select. Then in the appropriate event, I would add in the second operation. For example, you could set the HeaderClickAction to Sort, and then in the AfterSortChange event of the grid, you could select the column that was sorted.