ویرایش عنوان گره های treeView در زمان اجرا
کد:
private void Form1_Load(object sender, EventArgs e)
{
TreeNode treeNode = new TreeNode("Windows");
treeView1.Nodes.Add(treeNode);
treeNode = new TreeNode("Linux");
treeView1.Nodes.Add(treeNode);
TreeNode node2 = new TreeNode("C#");
TreeNode node3 = new TreeNode("VB.NET");
TreeNode[] array = new TreeNode[] { node2, node3 };
treeNode = new TreeNode("www.ashiyane.org", array);
treeView1.Nodes.Add(treeNode);
}
private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.E)
{
treeView1.LabelEdit = true;
TreeNode editNode = treeView1.GetNodeAt(
treeView1.PointToClient(System.Windows.Forms.Control.MousePosition));
if (editNode != null)
{
editNode.BeginEdit();
}
}
}
private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
treeView1.LabelEdit = false;
}