RadGridView: ColumnChooser - Get Info when a Column added or removed

1 Answer 60 Views
GridView
Dennis
Top achievements
Rank 1
Dennis asked on 28 Nov 2023, 03:27 PM

Hi,

I use the RadGridView and want to save the Layout for the customers. Everytime they change anything on the RadGridView, the Layout should be saved. And when the open the form with the grid again or load new data, the layout should be load.

If I change the column with, I can save it after "ColumnWidthChanged".
But I can't find an event for the adding oder removing of Columns.

I use the ColumnChooser. But I can't get, when a column was added or removed.

Any ideas to solve my problem?

Maybe another way is more helpful?

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 29 Nov 2023, 10:34 AM

Hi Dennis,

In order to detect when a column is dragged to the ColumnChooser, you can subscribe to the PropertyChanged event of the GridViewColumn. This event will be fired for the "IsVisible" property:

public Form1()
{
    InitializeComponent();
    foreach (GridViewColumn col in this.radGridView1.Columns)
    {
        col.PropertyChanged += col_PropertyChanged;
    }
}
 
private void col_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName == "IsVisible")
    {
         
    }
}

The sender in the col_PropertyChanged will be the column. I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Dennis
Top achievements
Rank 1
commented on 29 Nov 2023, 12:21 PM

YES!

Thats it. Great, thank you for the fast answer :)

Tags
GridView
Asked by
Dennis
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or