Home Forums WPF controls Xceed DataGrid for WPF AllowColumnReorder on specific columns

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

    Is there any way to allow the users to reorder only some columns?

    Setting the AllowColumnReorder, on the ColumnManagerRow, allows me to turn the reordering off for the entire table. But I would like to be able to do this on a column by column basis. for example: Disallow re-ordering on columns 1 to 4, yet allow the remaining columns to be reordered.

     Thanks for your help

    Imported from legacy forums. Posted by Liam (had 671 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Liam, 

    When re-ordering the position of a Column, the CollectionChanged event of the Columns collection would be called for every column that is re-positioned. 

    For your requirement, you can handle the collection changed event and set the order of the columns there. you can check first if the VisibleColumns.Count is equal to the number of columns before doing your implementation, it should look something like this: 

      public void VisibleColumns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                if (grid.VisibleColumns.Count == 4)
                {
                    Dispatcher.BeginInvoke(new ReorderDelegate(reorder), null);
                }
            }

    Find attached a sample application that I have created earlier that detects when columns are reordered and resets their order, it uses the CollectionChanged event of the VisibleColumns and it should help you get started to disallow reordering a specific range of columns. 

     

    Imported from legacy forums. Posted by Michel [Xceed] (had 595 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    The following feature was included in DataGrid for WPF v6.1:

    “A column can now be set to be “undraggable” and fixed either at the start or the end of columns.”

    Download Link: http://forums.xceed.com/latest-xceed-datagrid-for-wpf

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