This is a migrated thread and some comments may be shown as answers.

Is It possible to sync two Grids layout?

3 Answers 201 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vicent
Top achievements
Rank 1
Iron
Vicent asked on 14 Sep 2018, 10:33 AM

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);
            }

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Sep 2018, 10:25 AM
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.
0
Vicent
Top achievements
Rank 1
Iron
answered on 17 Sep 2018, 10:47 AM

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?

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Sep 2018, 08:13 AM
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.
Tags
GridView
Asked by
Vicent
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Vicent
Top achievements
Rank 1
Iron
Share this question
or