RadPropertyChanged event of columns not fired after loading grid layout

7 posts, 1 answers
  1. Johannes
    Johannes avatar
    66 posts
    Member since:
    Dec 2012

    Posted 08 Feb 2013 Link to this post

    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?
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 13 Feb 2013 Link to this post

    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.
  3. Johannes
    Johannes avatar
    66 posts
    Member since:
    Dec 2012

    Posted 14 Feb 2013 Link to this post

    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.
  4. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 19 Feb 2013 Link to this post

    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.
  5. pierre-jean
    pierre-jean avatar
    113 posts
    Member since:
    Apr 2011

    Posted 09 Dec 2019 in reply to Stefan Link to this post

    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

  6. Nadya
    Admin
    Nadya avatar
    280 posts

    Posted 12 Dec 2019 Link to this post

    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.
  7. pierre-jean
    pierre-jean avatar
    113 posts
    Member since:
    Apr 2011

    Posted 12 Dec 2019 in reply to Nadya Link to this post

    Hello Nadya

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

    Best regards

Back to Top