treeView and KeyDown question

treeView and KeyDown question

Post by meh » Thu, 10 Jun 2004 22:17:30


his is a multi-part message in MIME format.


I have a treeView that I'm trapping key strokes like below. It works fine as long as I dont define shortcut keys in the Context Menu assigned to the treeView for those keys. Can someone tell me what I'm doing wrong?

private void treeView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)

{
if (treeView1.SelectedNode != null)
{
if (treeView1.SelectedNode.IsEditing)
{
return; // Get out if editing
}
}
if (e.KeyCode == Keys.Insert)
{
// Do Stuff1;
if (e.Control) // if CTRL+Insert key is pressed
{
// Do Stuff2:
}
else if (e.Shift) // if SHIFT+Insert key is pressed
{
// Do Stuff3;
}
else // if just Insert key is pressed
{
// Do Stuff4;
}
}
}

Thanks in advance for any help or advice....
meh
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>I have a treeView that I'm trapping key strokes
like below.  It works fine as long as I dont define shortcut keys in the
Context Menu assigned to the treeView for those keys.  Can someone tell me
what I'm doing wrong?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<P><FONT face=Arial size=2>private void treeView1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)</FONT></P></DIV>
<DIV><FONT face=Arial size=2>{</FONT></DIV>
<DIV><FONT face=Arial size=2>    if (treeView1.SelectedNode !=
null) </FONT></DIV>
<DIV><FONT face=Arial size=2>       
    { </FONT></DIV>
<DIV><FONT face=Arial size=2>       
        if (treeView1.SelectedNode.IsEditing)
</FONT></DIV>
<DIV><FONT face=Arial size=2>   
           { </FONT></DIV>
<DIV><FONT face=Arial size=2>       
        return; // Get out if editing</FONT></DIV>
<DIV><FONT face=Arial size=2>       
        } </FONT></DIV>
<DIV><FONT face=Arial size=2>       
    } </FONT></DIV>
<DIV><FONT face=Arial size=2>    if (e.KeyCode == Keys.Insert)
</FONT></DIV>
<DIV><FONT face=Arial size=2>        {
</FONT></DIV>
<DIV><FONT face=Arial size=2>        // Do
Stuff1; </FONT></DIV>
<DIV><FONT face=Arial size=2>        if
(e.Control) // if CTRL+Insert key is pressed &l
 
 
 

1. Here is the syntax for TreeView.KeyDown().

2. Treeview, avoid selecting node on keydown or up

Is there a way to avoid the behaviour of the userform treeview control where
a different node gets selected when the node text starts with the letter of
the pressed key.
The problem is that I have keyboard shortcuts that do various things in the
treeview and these get messed up by this.
These routines get triggered by the keyup event. Can't remember now why this
isn't in the keydown event, but there was a good reason for it.

RBS

3. Can't use Keydown event in treeview

4. Treeview & keydown

5. Can't use Keydown event in treeview

6. Wireless Authentication ands Ecryption Question

7. two questions: and's inside if's and checking the return code of a program

8. Question on KeyDown Event

9. EDIT BOX, FOCUS, KEYDOWN question

10. 2 questions about KeyDown/Up Events

11. Keydown question

12. KeyDown Event Question

13. Nesting ,Ands

14. Specify list items with unlimited ANDs and ORs?