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 271571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:11:06+00:00 2026-05-12T00:11:06+00:00

So I have a TreeView that starts off empty. Sequence of events is as

  • 0

So I have a TreeView that starts off empty. Sequence of events is as follows:

  1. Add a new root node. Code makes the label edit box pop up immediately, and I give it a name.
  2. Add a new subnode to that root node.
  3. Add a new root node, after the first one. The label edit box pops up, and I give it a name.

The second root node takes on its new name, but so does the subnode added in step #2. Now, it’s not really the subnode’s text; if I examine that TreeNode in the debugger, it has the proper text for a subnode. But that text that was entered into the root node sticks around through expanding and collapsing its parent node, until something else happens and I need to rebuild the tree.

I’m building the tree in kind of an odd way—removing all root nodes from the parent, all child nodes from the root, updating all the tags and text, creating new nodes, then re-adding the nodes to their parents—but I’ve checked, and the proper text is being associated with the proper node. The TreeNode that is showing the wrong text has only ever modeled the one object, never had anything else in its Text property, and has its text set back to the right value (“untitled action”) right before being re-added to its parent node.

All I can think of for a culprit is the code for the label editing box, which is based on an MSDN sample:

Private Sub EditSelectedCategoryName()
    If Not ActionList.SelectedNode.IsEditing Then
        ActionList.LabelEdit = True
        ActionList.SelectedNode.BeginEdit()
    End If
End Sub

Private Sub ActionList_AfterLabelEdit(ByVal sender As Object, ByVal e As NodeLabelEditEventArgs) Handles ActionList.AfterLabelEdit
    If e.Label IsNot Nothing Then
        e.Node.EndEdit(False)
        CType(e.Node.Tag, ImportActionCategory).DisplayName = e.Label
    Else
        e.Node.EndEdit(True)
    End If
    ActionList.LabelEdit = False
End Sub

EditSelectedCategoryName is called by a context menu item’s Click event, right after the new root node is added and made the selected node. The DisplayName setter in the AfterLabelEdit event handler is what triggers another chain of events that rebuilds the tree. So am I screwing up some internal structure of the TreeView by altering its contents in the AfterLabelEdit event?

  • 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-05-12T00:11:07+00:00Added an answer on May 12, 2026 at 12:11 am

    I added

    e.CancelEdit = True
    

    right at the end of the AfterLabelEdit handler, and the problem went away. Apparently I was futzing with some assumed invariant of the TreeView…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TreeView that launches a new window when each of its TreeViewItems
I have a TreeView that is generated in code, and will look like this
I am new in WPF world. I have treeView that contains Treeview Mandate -->
I have a TreeView control, and after a new node is added, I need
I have a treeview that is bound to a collection and each item in
I have a TreeView that is bound to a XmlDataSource control. I've added some
I have a TreeView that permits the user to select different items. The display
I have a treeview control that functions like a folder browser. Because loading the
So in my project i would like have a nice treeview that has images.
I have a winforms TreeView control that allows you to browse an object hierarchy.

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.