Designer view:
#region DesignerView
Create a context menu strip :
this.copyPathMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyPathMenuItem});
this.labelContextMenuStrip.Name = "labelContextMenuStrip";
this.labelContextMenuStrip.Size = new System.Drawing.Size(100, 22);
this.copyPathMenuItem.Name = "copyPathMenuItem";
this.copyPathMenuItem.Size = new System.Drawing.Size(100, 22);
this.lblSelectedNodePath.ContextMenuStrip = this.labelContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem copyPathMenuItem;
#endregion
Now handles the label events like :-
private void lblSelectedNodePath_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
copyPathMenuItem.Visible = true;
copyPathMenuItem.Enabled = true;
}
}
Add an click event :-
copyPathMenuItem.Click += new EventHandler(copyPathMenuItem_Click);
Handles the click event :-
private void copyPathMenuItem_Click(object sender, EventArgs e)
{
string labelPath = lblSelectedNodePath.Text.Trim();
if (!string.IsNullOrEmpty(labelPath))
{
Clipboard.SetDataObject(labelPath, false);
}
}
Now you can paste your copy text anywhere Enjoy d Code .....
#region DesignerView
Create a context menu strip :
this.copyPathMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyPathMenuItem});
this.labelContextMenuStrip.Name = "labelContextMenuStrip";
this.labelContextMenuStrip.Size = new System.Drawing.Size(100, 22);
this.copyPathMenuItem.Name = "copyPathMenuItem";
this.copyPathMenuItem.Size = new System.Drawing.Size(100, 22);
this.lblSelectedNodePath.ContextMenuStrip = this.labelContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem copyPathMenuItem;
#endregion
Now handles the label events like :-
private void lblSelectedNodePath_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
copyPathMenuItem.Visible = true;
copyPathMenuItem.Enabled = true;
}
}
Add an click event :-
copyPathMenuItem.Click += new EventHandler(copyPathMenuItem_Click);
Handles the click event :-
private void copyPathMenuItem_Click(object sender, EventArgs e)
{
string labelPath = lblSelectedNodePath.Text.Trim();
if (!string.IsNullOrEmpty(labelPath))
{
Clipboard.SetDataObject(labelPath, false);
}
}
Now you can paste your copy text anywhere Enjoy d Code .....