Home Forums WinForms controls Xceed Grid for WinForms disable sorting

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13781 |

    Is there a property I can set that will disable sorting in a grid?

    I can do this:
    foreach (Column column in this.grid.Columns) {
    column.CanBeSorted = false;
    }
    but it seems that there should a single property somewhere I can just set.

    Thanks,
    Marcus

    Imported from legacy forums. Posted by MarcusCuda (had 4487 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t think there is such a property.

    Imported from legacy forums. Posted by Tommy (had 272 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Guys,

    The ColumnManagerRow has an AllowSort property that you could use to prevent columns from being sorted when you clink on a ColumnManagerCell.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 421 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny,

    Thanks for the response. How do I get a reference to a Grid’s ColumnManagerRow? I was looking through the Class Reference, I couldn’t see how to.

    Thanks,
    Marcus

    Imported from legacy forums. Posted by MarcusCuda (had 570 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Marcus,

    All depends on where it is located. By default, the ColumnManagerRow is the second row in the grid’s collection of FixedHeaderRows so it could be accessed in the following manner:

    ( ( ColumnManagerRow )grid.FixedHeaderRows[ 1 ] ).AllowSort = False

    Of course, you should first check if the type of the second row is actually a ColumnManagerRow 😉

    If you are using the designer, you could also simply access the object directly. By default, its name is columnManagerRow1.

    I hope this helps.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 364 views)

    User (Old forums)
    Member
    Post count: 23064

    Here’s some code to find the ColumnManagerRow programmatically, in all situations:<code>foreach(Row row in grid.FixedHeaderRows) {
    ColumnManagerRow cmRow = row as ColumnManagerRow;
    if (cmRow != null) {
    cmRow.AllowSort = false;
    break;
    }
    }</code>

    Imported from legacy forums. Posted by Tommy (had 284 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Jenny and Tommy, that is exactly what I need.

    Marcus

    Imported from legacy forums. Posted by MarcusCuda (had 5668 views)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.