Is It possible to sync two Grids layout?

4 posts, 0 answers
  1. Vicent
    Vicent avatar
    9 posts
    Member since:
    Mar 2015

    Posted 14 Sep 2018 Link to this post

    I want users to be able to modify columns width, order, pinned state, ... But at the same time, I have two grids in the same form one above the other and I would like to sync layout of both.

     

    I have tried to use somthing like this, but it is not working:

                foreach (var col in this.grid1.Columns)
                {
                    this.grid2.Columns.Add(col);
                }

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3715 posts

    Posted 17 Sep 2018 Link to this post

    Hello, Vicent,

    Save/Load layout functionality that RadGridView offers gives your applications the opportunity to preserve user grid settings such as column order and restore them later. Those layout settings are written in a XML file. This may be a suitable approach for achieving the requirement that you have: https://docs.telerik.com/devtools/winforms/gridview/save-and-load-layout/save-and-load-layout

    I hope this information helps.

    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Vicent
    Vicent avatar
    9 posts
    Member since:
    Mar 2015

    Posted 17 Sep 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    I had already thought about that, saving layout from grid1 and loading into grid2 everytime a change is made.

    I found an event ColumnWidthChanged but I can't find an event when colum is reordered, pinned or custom formatting changed.

    Does such events exists?

     

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3715 posts

    Posted 18 Sep 2018 Link to this post

    Hello, Vicent,  

    The RadGridView.Columns.CollectionChanged event is fired when the users reorder the columns. When you pin a column, the GridViewDataColumn.PropertyChanged event is fired where in the event args the PropertyName indicates that the PinPosition is modified. The GridViewDataColumn.ConditionalFormattingObjectList.CollectionChanged event is fired when you manipulate the conditional formatting:
     
    public RadForm1()
    {
        InitializeComponent();
     
        this.radGridView1.Columns.CollectionChanged+=Columns_CollectionChanged;
        foreach (GridViewDataColumn col in this.radGridView1.Columns)
        {
            col.PropertyChanged+=col_PropertyChanged;
            col.ConditionalFormattingObjectList.CollectionChanged+=ConditionalFormattingObjectList_CollectionChanged;
        }
    }
     
    private void ConditionalFormattingObjectList_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
    {
        Console.WriteLine(e.Action);
    }
     
    private void Columns_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
    {
        Console.WriteLine(e.Action);
    }
     
    private void col_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        Console.WriteLine(e.PropertyName);
    }

     
    I hope this information helps. 

    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top