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
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
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.
Greetings,
Stefan
the Telerik team
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
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
Hello Nadya
Thanks a lot that's exactly what I was looking for
Best regards