Remove a Pane Programmatically

2 posts, 0 answers
  1. Todd Bush
    Todd Bush avatar
    3 posts
    Member since:
    Oct 2009

    Posted 30 Apr 2010 Link to this post

    I have successfully added some panes programmatically and now would like to remove the same pane programmatically however I cannot work out how to get a reference to the pane I would like to remove by using the name only (this is being called from an external page which does not have a reference to the pane collection).

    The code to add my panes:

    public void AddPane(String Name, String Type)
    RadPane panelTable = new RadPane();
    panelTable.Header = "Table:" + Name;
    panelTable.Title = Name;
    panelTable.Name = Name;
    aDashTable aPaneTable = new aDashTable();
    panelTable.Content = aPaneTable;
    radPaneGroupMain.AddItem(panelTable, DockPosition.Left);

    Attempting to remove my panes with:

    public void RemovePane(String Name, String Type)
    RadPane paneTable = new RadPane();
    paneTable = radPaneGroupMain.FindName("Table:" + Name) as RadPane;

    But this does not work. The paneTable object is null. Any thoughts?

  2. Miroslav Nedyalkov
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 04 May 2010 Link to this post

    Hi Stewart,

     Instead of using the pane group you could the Docking control and its Panes property - it will give you an IEnumerable<RadPane> and you could find the pane in this enumerable. After that the RadPane has RemoveFromParent method that will remove it wherever it is. Please refer to the following code:

    private void RemovePane(string name)
     dock.Panes.First(pane => pane.Name == name).RemoveFromParent();

    Hope this helps!

    All the best,
    Miroslav Nedyalkov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top