Mega Code Archive

 
Categories / C# / GUI Windows Form
 

LinkLabel Clicked event

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; public class Form1 : Form {       private System.Windows.Forms.LinkLabel driveLinkLabel;       private System.Windows.Forms.LinkLabel deitelLinkLabel;       private System.Windows.Forms.LinkLabel notepadLinkLabel;              public Form1() {         InitializeComponent();       }       private void driveLinkLabel_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )       {         driveLinkLabel.LinkVisited = true;         System.Diagnostics.Process.Start( @"C:\" );       }        private void deitelLinkLabel_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )       {         deitelLinkLabel.LinkVisited = true;         System.Diagnostics.Process.Start( "IExplore", "http://www.rntsoft.com" );       }       private void notepadLinkLabel_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )       {          notepadLinkLabel.LinkVisited = true;          System.Diagnostics.Process.Start( "notepad" );       }       private void InitializeComponent()       {          this.driveLinkLabel = new System.Windows.Forms.LinkLabel();          this.deitelLinkLabel = new System.Windows.Forms.LinkLabel();          this.notepadLinkLabel = new System.Windows.Forms.LinkLabel();          this.SuspendLayout();          //           // driveLinkLabel          //           this.driveLinkLabel.AutoSize = true;          this.driveLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));          this.driveLinkLabel.Location = new System.Drawing.Point(28, 24);          this.driveLinkLabel.Name = "driveLinkLabel";          this.driveLinkLabel.Size = new System.Drawing.Size(133, 20);          this.driveLinkLabel.TabIndex = 0;          this.driveLinkLabel.TabStop = true;          this.driveLinkLabel.Text = "Click to browse C:\\";          this.driveLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.driveLinkLabel_LinkClicked);          //           // deitelLinkLabel          //           this.deitelLinkLabel.AutoSize = true;          this.deitelLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));          this.deitelLinkLabel.Location = new System.Drawing.Point(28, 68);          this.deitelLinkLabel.Name = "deitelLinkLabel";          this.deitelLinkLabel.Size = new System.Drawing.Size(198, 20);          this.deitelLinkLabel.TabIndex = 1;          this.deitelLinkLabel.TabStop = true;          this.deitelLinkLabel.Text = "Click to visit www.rntsoft.com";          this.deitelLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.deitelLinkLabel_LinkClicked);          //           // notepadLinkLabel          //           this.notepadLinkLabel.AutoSize = true;          this.notepadLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));          this.notepadLinkLabel.Location = new System.Drawing.Point(28, 114);          this.notepadLinkLabel.Name = "notepadLinkLabel";          this.notepadLinkLabel.Size = new System.Drawing.Size(147, 20);          this.notepadLinkLabel.TabIndex = 2;          this.notepadLinkLabel.TabStop = true;          this.notepadLinkLabel.Text = "Click to run Notepad";          this.notepadLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.notepadLinkLabel_LinkClicked);          //           // LinkLabelTestForm          //           this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;          this.ClientSize = new System.Drawing.Size(261, 164);          this.Controls.Add(this.notepadLinkLabel);          this.Controls.Add(this.deitelLinkLabel);          this.Controls.Add(this.driveLinkLabel);          this.Name = "LinkLabelTestForm";          this.Text = "LinkLabelTest";          this.ResumeLayout(false);          this.PerformLayout();       }       [STAThread]       static void Main()       {         Application.EnableVisualStyles();         Application.Run(new Form1());       } }