KeyEventArgs.KeyCode例子 private void treeView1_KeyDown(object sender, KeyEventArgs e) { /* If the 'Alt' and 'E' keys are pressed, * allow the user to edit the TreeNode label. */ if(e.Alt && e.KeyCode == Keys.E)
{ treeView1.LabelEdit = true; // If there is a TreeNode under the mose cursor, begin editing. TreeNode editNode = treeView1.GetNodeAt( treeView1.PointToClient(Control.MousePosition)); if(editNode != null) { editNode.BeginEdit(); } } }
private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
/* If the 'Alt' and 'E' keys are pressed,
* allow the user to edit the TreeNode label. */
if(e.Alt && e.KeyCode == Keys.E)
{
treeView1.LabelEdit = true;
// If there is a TreeNode under the mose cursor, begin editing.
TreeNode editNode = treeView1.GetNodeAt(
treeView1.PointToClient(Control.MousePosition));
if(editNode != null)
{
editNode.BeginEdit();
}
}
}
所谓的Key指主键值,举个例子:用imagelist添加image对象,默认是索引号,但我可以对它赋予明确的一个访问值,如imagelist.images[0].key="open",而我用toolbar.button[0].imageindex="open"
这样指定就可以了。它会自动的指向该索引号0的图象,toolbar的button也有同样的key值,
toolbar.button["new"].visible=true就可以了,而不去记它的索引号,更有利于编程。