Re: C# question: How do you delete a Grid object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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?


.



Relevant Pages

  • Re: Setting controls.Visible = False still takes up space
    ... Properties of your main page> You want Flow Control instead of Grid ... if I highlight a control on my page and go to Layout> ... I think the problem is that I am using a Panel to place a GridView ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: outlook 07 TODO bar! PLEASE HELP!!
    ... Remember Outlook was not written in .NET... ... If its easiest for you to implement it as a Panel, then by all means use a ... has over a Control). ... The grid supports grouping. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: outlook 07 TODO bar! PLEASE HELP!!
    ... If its easiest for you to implement it as a Panel, then by all means use a Panel. ... Although I would probably start with a Control, or possibly even a UserControl. ... Hint to create your own To Do bar for Outlook you would create an Outlook 2007 Region, which in .NET is based on a UserControl. ... The grid supports grouping. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Form as a control?
    ... Chris wrote: ... > When a new form needs this grid, I would, say, take the form ... > and add it to a panel as a child control ... ... Instead of a form as a base for you grid, use a panel. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to fire an event
    ... I have an Infragistic datagrid control, ... The button click event is being raised upon a post-back to the server. ... manipulating the grid in script would cause a server event to be raised. ... The problem here is that I have no idea whether the grid will raise the ...
    (microsoft.public.dotnet.languages.csharp)