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

Remove a Pane Programmatically

1 Answer 51 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Todd Bush
Top achievements
Rank 1
Todd Bush asked on 30 Apr 2010, 07:07 AM
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;
radPaneGroupMain.RemovePane(paneTable);
}

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

1 Answer, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 04 May 2010, 12:29 PM
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.
Tags
Docking
Asked by
Todd Bush
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Share this question
or