How when loading the program, no treeview mode is selected - C++ WInforms

José Carlos 886 Reputation points
2023-04-04T12:58:49.1766667+00:00

Hi friends, In design mode I put two parent nodes and some child nodes. When I load the program, the first parent node is already selected. I need that when loading, no node is selected. I tried a few times here but it didn't work. I'm studying this control. I tried the following code but it didn't work. I put it in the formload.

			for each (TreeNode^ node in treeView1->Nodes)
			{
				if (node->IsSelected)
					treeView1->SelectedNode = nullptr;
			}

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,416 Reputation points
    2023-04-04T14:48:59.7866667+00:00

    You can add a Shown handler in the Designer and :

    private: System::Void Form1_Shown(System::Object^ sender, System::EventArgs^ e)
    {	
    	treeView1->SelectedNode = nullptr;
    }
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.