473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

TreeView AfterLabelEdit - no work

bob
Hello,

the nodes in my tree view show a name and then a suffix. I want to be
able to edit the name using 'label edit' but I want the suffix to be
removed and then added after the edit. I try this with the events
AfterLabelEdit and BeforeLabelEdit but they don't do anything. The
following bit of code just has a tree view with some nodes and has
BeforeLabelEdit set to change the node text to 'editing':

private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}
But it doesn't do anything.

Any one have any ideas?

sorry about the long post

Thanks,

Bob
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TreeViewTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.ImageIndex = -1;
this.treeView1.LabelEdit = true;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node1", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node4", new
System.Windows.Forms.TreeNode[] {

new System.Windows.Forms.TreeNode("Node5"),

new System.Windows.Forms.TreeNode("Node6")})}),
new
System.Windows.Forms.TreeNode("Node2", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node3")})})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(292, 266);
this.treeView1.TabIndex = 1;
this.treeView1.AfterLabelEdit += new
System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_AfterLabelEdit);
this.treeView1.BeforeLabelEdit += new
System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_BeforeLabelEdit);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Edited";
}
}
}
Nov 16 '05 #1
3 7753
Do this in AfterLabel Edit event

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
string text = e.Label;
e.CancelEdit = true;
e.Node.Text = "Edited: " + text;
}

--
Shak
(Houston)


"bob" <bo**********@hotmail.com> wrote in message
news:b0*************************@posting.google.co m...
Hello,

the nodes in my tree view show a name and then a suffix. I want to be
able to edit the name using 'label edit' but I want the suffix to be
removed and then added after the edit. I try this with the events
AfterLabelEdit and BeforeLabelEdit but they don't do anything. The
following bit of code just has a tree view with some nodes and has
BeforeLabelEdit set to change the node text to 'editing':

private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}
But it doesn't do anything.

Any one have any ideas?

sorry about the long post

Thanks,

Bob
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TreeViewTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.ImageIndex = -1;
this.treeView1.LabelEdit = true;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node1", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node4", new
System.Windows.Forms.TreeNode[] {

new System.Windows.Forms.TreeNode("Node5"),

new System.Windows.Forms.TreeNode("Node6")})}),
new
System.Windows.Forms.TreeNode("Node2", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node3")})})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(292, 266);
this.treeView1.TabIndex = 1;
this.treeView1.AfterLabelEdit += new
System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_AfterLabelEdit
); this.treeView1.BeforeLabelEdit += new
System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_BeforeLabelEdi
t); //
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Edited";
}
}
}

Nov 16 '05 #2
bob
Thanks for your help Shak, your tip fixes the AfterLabelEdit event.

But what about the BeforeLabelEdit event, I still don't seem to be
able to change the text at the start of the edit operation.

Any ideas?
"Shakir Hussain" <sh**@fakedomain.com> wrote in message news:<e4**************@TK2MSFTNGP11.phx.gbl>...
Do this in AfterLabel Edit event

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
string text = e.Label;
e.CancelEdit = true;
e.Node.Text = "Edited: " + text;
}

--
Shak
(Houston)


"bob" <bo**********@hotmail.com> wrote in message
news:b0*************************@posting.google.co m...
Hello,

the nodes in my tree view show a name and then a suffix. I want to be
able to edit the name using 'label edit' but I want the suffix to be
removed and then added after the edit. I try this with the events
AfterLabelEdit and BeforeLabelEdit but they don't do anything. The
following bit of code just has a tree view with some nodes and has
BeforeLabelEdit set to change the node text to 'editing':

private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}
But it doesn't do anything.

Any one have any ideas?

sorry about the long post

Thanks,

Bob
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TreeViewTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}

base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.ImageIndex = -1;
this.treeView1.LabelEdit = true;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node1", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node4", new
System.Windows.Forms.TreeNode[] {

new System.Windows.Forms.TreeNode("Node5"),

new System.Windows.Forms.TreeNode("Node6")})}),
new
System.Windows.Forms.TreeNode("Node2", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node3")})})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(292, 266);
this.treeView1.TabIndex = 1;
this.treeView1.AfterLabelEdit += new

System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_AfterLabelEdit
);
this.treeView1.BeforeLabelEdit += new

System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_BeforeLabelEdi
t);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Edited";
}
}
}

Nov 16 '05 #3
As Shakir once told me, try the OnClick() event.

Thanks,
Michael C.

"bob" <bo**********@hotmail.com> wrote in message
news:b0**************************@posting.google.c om...
Thanks for your help Shak, your tip fixes the AfterLabelEdit event.

But what about the BeforeLabelEdit event, I still don't seem to be
able to change the text at the start of the edit operation.

Any ideas?
"Shakir Hussain" <sh**@fakedomain.com> wrote in message

news:<e4**************@TK2MSFTNGP11.phx.gbl>...
Do this in AfterLabel Edit event

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
string text = e.Label;
e.CancelEdit = true;
e.Node.Text = "Edited: " + text;
}

--
Shak
(Houston)


"bob" <bo**********@hotmail.com> wrote in message
news:b0*************************@posting.google.co m...
Hello,

the nodes in my tree view show a name and then a suffix. I want to be
able to edit the name using 'label edit' but I want the suffix to be
removed and then added after the edit. I try this with the events
AfterLabelEdit and BeforeLabelEdit but they don't do anything. The
following bit of code just has a tree view with some nodes and has
BeforeLabelEdit set to change the node text to 'editing':

private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}
But it doesn't do anything.

Any one have any ideas?

sorry about the long post

Thanks,

Bob
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TreeViewTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}

base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.ImageIndex = -1;
this.treeView1.LabelEdit = true;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node1", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node4", new
System.Windows.Forms.TreeNode[] {

new System.Windows.Forms.TreeNode("Node5"),

new System.Windows.Forms.TreeNode("Node6")})}),
new
System.Windows.Forms.TreeNode("Node2", new
System.Windows.Forms.TreeNode[] {
new
System.Windows.Forms.TreeNode("Node3")})})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(292, 266);
this.treeView1.TabIndex = 1;
this.treeView1.AfterLabelEdit += new

System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_AfterLabelEdit );
this.treeView1.BeforeLabelEdit += new

System.Windows.Forms.NodeLabelEditEventHandler(thi s.treeView1_BeforeLabelEdi t);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void treeView1_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Editing";
}

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.Text = "Edited";
}
}
}

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: .pd. | last post by:
I created a Windows form and stuck a toolbar on it with one button. I then added a treeView, docked it to the left of the form and enabled Label Edit. Here's the toolbar button click and after...
0
by: Andres Romero | last post by:
How can I catch the Key event in a treeview before the AfterLabelEdit event to catch the Escape key? My code has both events declared in the treeview, but the first executed is the afterlabeledit...
7
by: Progalex | last post by:
Hi everybody! I have a listview and a treeview in a form . With an OpenDialog I let the user select multiple files and then these files are added to the listview with the complete pathname,...
2
by: casmang | last post by:
I am having the problem where when I change the font of a TreeNode in a TreeView to a bold property, the bounds or rectangle that draws the node does not expand so that the text ends up being cut...
2
by: metaperl | last post by:
Hello, I'm trying to get the MSDN documentation example of a treeview to work: http://msdn2.microsoft.com/en-us/library/system.windows.forms.treeview.aspx I made the function static and added a...
2
by: Pucca | last post by:
Hi, When the user select a tree node, right click and select the "Rename" option in my context menu, I would like to create the Edit Label ability for the user. I would like to have the blinking...
0
by: noneya22 | last post by:
I want to use a TreeView control as a one-level, vertical navigation menu. I'm using this control currently with a SiteMapDataSource and .sitemap file. I've written code that associates an image...
0
by: Joe Stateson | last post by:
I had thought that checkbox changes in a treeview only work at postback but I found this code that makes it work (sort of) on client click http://www.developerfusion.co.uk/forums/p/33913/149877/ ...
0
by: SMJT | last post by:
Hi all I have a form with a treeview on it. I add 3 nodes and enable LabelEditing. In the AfterLabelEdit event code I want to change the SelectedNode on the treeview however it doesn't always...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.