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

  • Home
  • SEARCH
  • 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 6213499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:42:26+00:00 2026-05-24T06:42:26+00:00

I have a node on a TreeView that I populate manually and want to

  • 0

I have a node on a TreeView that I populate manually and want to keep sorted. Through user interaction the headers on the TreeViewItem’s may change and they should move to the appropriate spot in the list.

I iterate through a foreach creating numerous TreeViewItem’s and adding them to a parent node. It is all of the children that need to be sorted. I then add a SortDescription as follows.

tviParent.Items.SortDescriptions.Add(new SortDescription("Header", ListSortDirection.Ascending));

This sorts the intial list, but if I change the header for one of the tree view items after it is displayed the item does not sort again. The header text changes, but the items position in the list remains the same.

Is there something I am missing?

I have tried clearning the list and repopulating it, which will work, however it causes some isues in my program as I have a lot of logic for when the selected item is changed and since one of the tree view items in the list that I am clearing is selected it invokes all of this logic when I clear the list and then again when I programmatically reselect the item after rebuilding the list.

  • 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-24T06:42:28+00:00Added an answer on May 24, 2026 at 6:42 am

    The items collection will have to be refreshed upon any change to its property

    try the following code after the header edit ….

      tviParent.Items.Refresh();
    

    if the code above does not work then try code below after each edit …

      tviParent.Items.SortDescriptions.Clear()
      tviParent.Items.SortDescriptions.Add(new SortDescription("Header", ListSortDirection.Ascending));  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make in a TreeView (winforms) that each node will have in
I have a treeView , and i want to know if some node can
I have UserControl that holds Infragistics Graph control. On the TreeView sub node's right
All my TreeView nodes have a unique ID for their Node Depth. I want
I have a TreeView and a multiline TextBox. When user clicks on a node
I have a wpf application that displays a 'Node' as such: <TreeView HorizontalAlignment=Stretch Name=treeView1
I have a TreeView that is binded through a HierarchicalDataTemplate <HierarchicalDataTemplate x:Key=HierachrTree DataType={x:Type src:Ordner}
i have a treview control with drag&drop functionality that response to draw the node
I have this TreeView: Main Node Header=Main Sub Node Header=Sub1 Final Node Header=Item1 Final
I have a WinForms TreeView with one main node and several sub-nodes. How can

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.