Label.Click : Label « System.Windows.Forms « C# / C Sharp by API






Label.Click

 

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

public class LabelWithGenericEvent : System.Windows.Forms.Form
{
  private System.Windows.Forms.Label lblTitle;

  public LabelWithGenericEvent()
  {
    InitializeComponent();
  }

  private void InitializeComponent()
  {
    this.lblTitle = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // 
    // lblTitle
    // 
    this.lblTitle.Location = new System.Drawing.Point(40, 24);
    this.lblTitle.Name = "lblTitle";
    this.lblTitle.Size = new System.Drawing.Size(150, 25);
    this.lblTitle.TabIndex = 0;
    this.lblTitle.Text = "Events Demonstrator";
    this.lblTitle.Click += new System.EventHandler(this.GenericEventHandler);
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(242, 173);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {  this.lblTitle});
    this.ResumeLayout(false);

  }
  [STAThread]
  static void Main() 
  {
    Application.Run(new LabelWithGenericEvent());
  }
  private void GenericEventHandler(object sender, EventArgs e)
  {
    MessageBox.Show("Generic event handler","Event Demo");
  }
}

   
  








Related examples in the same category

1.Label.Background
2.Label.DataBindings
3.Label.DoDragDrop
4.Label.Image
5.Label.ImageAlign
6.Label.ImageIndex
7.Label.ImageList
8.Label.Localtion
9.Label.Margin
10.Label.MouseDown
11.Label.MouseHover
12.Label.MouseMove
13.Label.MouseUp
14.Label.Size
15.Label.Text