Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
HideSelection Property

TreeView::HideSelection Property

Gets or sets a value indicating whether the selected tree node remains highlighted even when the tree view has lost the focus.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
property bool HideSelection {
	bool get ();
	void set (bool value);
}

Property Value

Type: System::Boolean
true if the selected tree node is not highlighted when the tree view has lost the focus; otherwise, false. The default is true.

When this property is set to false, selected nodes in the TreeView control remain highlighted in a different color than the current selection color when the TreeView control loses focus. You can use this property to keep items that are selected by the user visible when the user clicks a different control on the form or moves to a different window.

NoteNote

If you are concerned with the accessibility of your applications, it is recommended that you set the HideSelection property to false.

The following code example demonstrates how to use the HideSelection property. To run this example, paste the following code in a form and call the InitializeSelectedTreeView method in the form's constructor or Load event handler.

   System::Windows::Forms::TreeView^ TreeView2;

   // Initialize the TreeView to blend with the form, giving it the  
   // same color as the form and no border. 
   void InitializeSelectedTreeView()
   {

      // Create a new TreeView control and set the location and size. 
      this->TreeView2 = gcnew System::Windows::Forms::TreeView;
      this->TreeView2->Location = System::Drawing::Point( 72, 48 );
      this->TreeView2->Size = System::Drawing::Size( 200, 200 );
      this->TreeView2->BorderStyle = BorderStyle::Fixed3D;

      // Set the HideSelection property to false to keep the  
      // selection highlighted when the user leaves the control.  
      this->TreeView1->HideSelection = false;

      // Add the nodes. 
      array<TreeNode^>^temp0 = {gcnew TreeNode( "Full Color" ),gcnew TreeNode( "Project Wizards" ),gcnew TreeNode( "Visual C# and Visual Basic Support" )};
      array<TreeNode^>^temp1 = {gcnew TreeNode( "Pentium 133 MHz or faster processor " ),gcnew TreeNode( "Windows 98 or later" ),gcnew TreeNode( "100 MB Disk space" )};
      array<TreeNode^>^temp2 = {gcnew TreeNode( "Features",temp0 ),gcnew TreeNode( "System Requirements",temp1 )};
      this->TreeView1->Nodes->AddRange( temp2 );

      // Set the tab index and add the TreeView to the form. 
      this->TreeView1->TabIndex = 0;
      this->Controls->Add( this->TreeView1 );
   }

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft