Remove RadPanelBarGroupElement from RadPanelbar at runtime

4 posts, 1 answers
  1. Walter
    Walter avatar
    5 posts
    Member since:
    Jul 2008

    Posted 24 Jul 2008 Link to this post

    Hello,

    I have a radpanelbar with 10 RadPanelBarGroupElements where i want to remove some RadPanelBarGroupElements at runtime. I use this:

    this.radPanelBar.Items.Remove(element); // element is a RadPanelBarGroupElement

    Inside each RadPanelBarGroupElement there is a radgridview.

    this shows up fine, but when the application exits, i get an argumentexception ("parameter is not valid")
    the stacktrace shows this:    at System.Drawing.Drawing2D.Matrix.Clone()

    if i do this instead:
    element.Visibility = ElementVisibility.Hidden;
    the error doesn't happen, and the element is hidden but still takes up space inside the panelbar (i don't want that).

    What is the best way to remove items from a radpanelbar?
    i used version 6.1.0.0

    Walter
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 24 Jul 2008 Link to this post

    Hello Walter,

    Thank you for contacting me.

    I would suggest you to use the Collapsed visibility state instead of Hidden? ElementVisibility.Hidden member only hides the element but it still has bounds, which affect the control's layout while the ElementVisibility.Collapsed member hides the element and its bounds do not affect the internal control's layout.

    Don't hesitate to contact me if you have further problems.

    Best wishes,
    Boyko Markov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Walter
    Walter avatar
    5 posts
    Member since:
    Jul 2008

    Posted 25 Jul 2008 Link to this post

    Hello Boyko,

    The elementVisibility.Collapsed didn't do the trick, but this did:

    for

    (int i = elementlist.Count; i > list.Count; i--)

    {

    RadPanelBarGroupElement element = elementlist[i - 1];

    RadGridView gridview = gridviewlist[i - 1];

    this.radPanelBar.Items.Remove(element);

    element.Dispose();

    gridview.Dispose();

    }

    gridview is the gridview inside the contentpanel.

    Grtz,


    walter

  5. Answer
    Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 25 Jul 2008 Link to this post

    Тhank you very much for the tip, Walter. I'm happy to hear that everything is fine now. Indeed, your approach seems better than mine.

    If you have any further questions please write us.
     

    Greetings,
    Boyko Markov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top