Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:08:37+00:00 2026-06-02T10:08:37+00:00

I have a TreeView on my winform which uses a subclass of TreeNode with

  • 0

I have a TreeView on my winform which uses a subclass of TreeNode with some additional variables I want to store against each node. Users can delete nodes from my tree using a context menu.

What I’d like to be able to do is extend the Remove method for TreeNode so that I do some extra processing in there before the node is removed. Is there a way to do this?

To clarify…

Is there a way to extend the existing Remove method for TreeNode so that code can be executed before it’s actually does the remove?

Cheers,

EDIT: Im actually assuming that the way i’ll have to do this is extend the class with a new method which calls this.Remove() instead?

EDIT 2: This is what I ended up doing. Is it the best way…

public partial class CustomTreeNode : TreeNode
{
    // My custom TreeNode vars
    public int UID;
    public int ParentUID;

    public CustomTreeNode(string nodeName) : base(nodeName)
    {
        // Set the tree node here
    }

    public void RemoveIt()
    {
        // Custom stuff
        System.Console.WriteLine("Deleted");

        base.Remove();
    } 

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:08:40+00:00Added an answer on June 2, 2026 at 10:08 am

    Try this in your sub-class

    public new void Remove() 
    { 
        //do your custom stuff
    
        base.Remove();  // calls the TreeNode Remove method
    }
    

    Edit: added new removed override

    Just be aware that any time you reference sub-class objects as a TreeNode then your custom Remove method will not be called Difference between new and override

    You could also name the function something else like this:

    public void SuperRemove() 
    { 
        //do your custom stuff
    
        base.Remove();  // calls the TreeNode Remove method
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeView , and i want to know if some node can
I want to make in a TreeView (winforms) that each node will have in
I have a treeview which contains, per node, a key and text. However, there
I have some TreeView's in my winform application. I am trying to make mass
I have a treeview in the winform application.... I added a node to it
I have a Winforms TreeView and I wish to store the node data into
I have a treeview control on * winform applica *tion. Here, what I want
I have treeview control with one level of parent and child nodes, each node
I have a treeview (winforms) which have different item types on it. I have
In the Winform, i have a UserControl TreeView and It loads real time data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.