Presidenten
Presidenten

Reputation: 6437

Disable key input in TreeView

I have a TreeView in my form for which I dont want to have key input enabled. Which means that if I have this tree structure:

Root
|
-- Abba
|
-- Basic
|
-- Center

...and press b key. I do not want "Basic" to be selected. I only want the user to be able to select nodes using mouse input.

Any ideas on how to achieve this?

Upvotes: 1

Views: 1527

Answers (2)

Searock
Searock

Reputation: 6498

in key press event of tree view

  if(Char.IsDigit(e.KeyChar) || Char.IsLetter(e.KeyChar))
  {
       e.Handled = true;
  }

Upvotes: 3

Sani Huttunen
Sani Huttunen

Reputation: 24395

First thought: You could overload the OnKey* events to do nothing.

Upvotes: 0

Related Questions