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

RadPropertyChanged event of columns not fired after loading grid layout

6 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Johannes asked on 08 Feb 2013, 11:36 AM
I have a RadGridView which Layout should be saved whenever a column is added or removed by the user via columnChooser.

I added this code in Form.OnLoad:

foreach (GridViewDataColumn column in  myGrid.Columns)
{
  column.RadPropertyChanged += GridViewColumn_RadPropertyChanged;
}

And here is GridViewColumn_RadPropertyChanged event:

if (e.Property.Name == "IsVisible")
{
  myGrid.SaveLayout(myPath);
}


This works fine - as long as I do not load an existing GridLayout. When I check in Form.OnLoad if there is an saved layout file and load that layout file for my Grid, the RadPropertyChanged event will not be fired anymore. Is there something additional I have to do with RadGridView after a layout has been loaded successfully?

6 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Feb 2013, 09:22 AM
Hi Johannes,

Thank you for writing.

A possible reason for the event not being fired is if you are not subscribing to it after you load the layout. Attached you can find a sample project, where I am initially loading the layout and the approach works correctly.

If you continue experiencing issues, please get back to me with a sample where it can be reproduced, so I can investigate the particular case and help you with it.

Greetings,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Johannes
Top achievements
Rank 1
answered on 14 Feb 2013, 09:42 AM
Hi Stefan,

Thank you for your suggestions. I moved the event subscription part after loading the layout and now the event will be fired as I expected.
0
Stefan
Telerik team
answered on 19 Feb 2013, 06:21 AM
I am glad I could help Johannes. Let us know if you need anything else.
 
Greetings,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 09 Dec 2019, 04:43 PM

Hello

To follow up on the above,
Is there a way to get the gridview that fired the radpropertychanged event,
i.e. to get the "myGrid" from the sender of the event

I can get the column:
Dim col as gridviewcolumn = trycast(sender,GridViewColumn)
but I dont see how to get the gridview itself ?

This would allow me to have a genereric handler for all the grids in my project.

Thanks in advance

Pierre-Jean

0
Nadya | Tech Support Engineer
Telerik team
answered on 12 Dec 2019, 08:52 AM

Hello Pierre-Jean,

Please refer to the following code snippet which demonstrates how you can access the RadGridView when handling the column.RadPropertyChanged event:

void column_RadPropertyChanged(object sender, Telerik.WinControls.RadPropertyChangedEventArgs e)
{
    GridViewColumn col = sender as GridViewColumn;
    RadGridView grid = col.OwnerTemplate.MasterTemplate.Owner;
}

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Nadya
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
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 12 Dec 2019, 09:02 AM

Hello Nadya

Thanks a lot that's exactly what I was looking for

Best regards

Tags
GridView
Asked by
Johannes
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Johannes
Top achievements
Rank 1
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Nadya | Tech Support Engineer
Telerik team
Share this question
or