rajeemcariazo
rajeemcariazo

Reputation: 2524

Set none selected in Winforms TreeView component

Initially, I want nothing selected on my TreeView. By default, the first node is selected/focused.The code

treeView1.SelectedNode = null;

didn't work.

Upvotes: 0

Views: 290

Answers (3)

A.M. Patel
A.M. Patel

Reputation: 334

Put your line of code

TreeView.HideSelection = false;

Upvotes: 0

SSS
SSS

Reputation: 5403

Put your line of code

treeView1.SelectedNode = null;

in the Form.Shown event, rather than in the Form.Load event. The default selection occurs after Form.Load, so you want to clear the selection after that.

Upvotes: 0

Ehsan.Saradar
Ehsan.Saradar

Reputation: 704

The tree node is not selected but has tap stop

treeView1.SelectedNode = null;
treeView1.TabStop = false;

Upvotes: 2

Related Questions