Re: C# question: How do you delete a Grid object
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Nov 2007 14:22:18 -0500
Turning the visible switch will not cause the GC to collect the object. It will just set the visibility of the control to false, as the reference to the object will still be held by the parent object.
I also don't know how you are using a Panel, and not a derived class, as Panel is marked abstract.
Regardless, any class that derives from Panel that you are using has a Children property which has all the child controls that are on the panel. Pass your Grid to the Remove method on the UIElementCollection that is exposed through the Children property and it will be removed.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<dongarbage@xxxxxxxxxxx> wrote in message news:1194718368.893261.240650@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm building an application (WPF) and I have a Panel in the
application which will be populated dynamically with objects of the
type Grid, TextBox, etc. For simplicity, let's say I'm just adding and
deleting Grid objects. I can add the objects easily by creating Grid
objects. The problem I have is that I don't know how to delete the
objects. How do you delete a Grid object? I'd prefer to not have to
turn the "visible" switch off and wait for the garbage collector to
come around.
Any ideas?
.
- Follow-Ups:
- Re: C# question: How do you delete a Grid object
- From: dongarbage
- Re: C# question: How do you delete a Grid object
- References:
- C# question: How do you delete a Grid object
- From: dongarbage
- C# question: How do you delete a Grid object
- Prev by Date: Re: WCF - compiler can't find TChannel
- Next by Date: window.open question
- Previous by thread: C# question: How do you delete a Grid object
- Next by thread: Re: C# question: How do you delete a Grid object
- Index(es):
Relevant Pages
|