Label.MouseDown : Label « System.Windows.Forms « VB.Net by API

Home
VB.Net by API
1.Microsoft.VisualBasic
2.Microsoft.Win32
3.System
4.System.Collections
5.System.Collections.Generic
6.System.Collections.Specialized
7.System.ComponentModel
8.System.Configuration.ConfigurationSettings
9.System.Data
10.System.Data.Odbc
11.System.Data.OleDb
12.System.Data.OracleClient
13.System.Data.SqlClient
14.System.Diagnostics
15.System.Drawing
16.System.Drawing.Drawing2D
17.System.Drawing.Imaging
18.System.Drawing.Printing
19.System.Drawing.Text
20.System.Globalization
21.System.IO
22.System.IO.IsolatedStorage
23.System.IO.Ports
24.System.Media
25.System.Messaging
26.System.Net
27.System.Net.Sockets
28.System.Reflection
29.System.Runtime.InteropServices
30.System.Runtime.Remoting.Channels
31.System.Runtime.Serialization
32.System.Runtime.Serialization.Formatters.Binary
33.System.Runtime.Serialization.Formatters.Soap
34.System.Security.Cryptography
35.System.Security.Cryptography.X509Certificates
36.System.Security.Permissions
37.System.Security.Principal
38.System.ServiceProcess
39.System.Text
40.System.Text.RegularExpressions
41.System.Threading
42.System.Web
43.System.Web.Mail
44.System.Windows.Forms
45.System.Xml
46.System.Xml.Schema
47.System.Xml.Serialization
48.System.Xml.Xsl
VB.Net
VB.Net Tutorial
VB.Net by API » System.Windows.Forms » Label 
Label.MouseDown
  


Option Strict On
imports System
imports System.Drawing
imports System.Windows.Forms

public class MouseEvents : inherits Form

  private lbl as Label
  private WithEvents btnReset as Button

  public sub New()
    Size = new Size(400,600)

    btnReset = new Button()
    btnReset.Parent = me
    btnReset.Location = new Point(250,50)
    btnReset.Text = "Reset"

    lbl = new Label()
    lbl.Parent = me
    lbl.Location = new Point(50,50)
    lbl.Size = new Size(250,250)
    lbl.BorderStyle = BorderStyle.Fixed3D
    
    AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter
    AddHandler lbl.MouseHover, AddressOf lbl_MouseHover
    AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave
    AddHandler lbl.MouseDown, AddressOf lbl_MouseDown
      AddHandler lbl.MouseMove, AddressOf lbl_MouseMove
    AddHandler lbl.MouseUp, AddressOf lbl_MouseUp
    AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel
    AddHandler lbl.Click, AddressOf lbl_Click
    AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick

  end sub

  public shared sub Main() 
    Application.Run(new MouseEvents())
  end sub

  private sub btnReset_Click(ByVal sender as object, _
                 ByVal e as EventArgs_
                   Handles btnReset.Click
    lbl.Text = ""
  end sub

  private sub lbl_MouseEnter(ByVal sender as object, _
                 ByVal e as EventArgs)
    lbl.Text = "MouseEnter"
    Console.WriteLine("Label MouseEnter")
  end sub

  private sub lbl_MouseHover(ByVal sender as object, _
                 ByVal e as EventArgs)
    lbl.Text = "MouseHover"
    Console.WriteLine("Label MouseHover")
  end sub

  private sub lbl_MouseLeave(ByVal sender as object, _
                 ByVal e as EventArgs)
    lbl.Text = "MouseLeave"
    Console.WriteLine("Label MouseLeave")
  end sub

  private sub lbl_MouseDown(ByVal sender as object, _
                ByVal e as MouseEventArgs)
    lbl.Text = "MouseDown"
    Console.WriteLine("Label MouseDown")
    Console.WriteLine("Button:  " + e.Button.ToString())
    Console.WriteLine("Clicks:  " + e.Clicks.ToString())
    Console.WriteLine("Delta:  " + e.Delta.ToString())
    Console.WriteLine("X:  " + e.X.ToString())
    Console.WriteLine("Y:  " + e.Y.ToString())
  end sub

  private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs)
    lbl.Text = "MouseMove"
    Console.WriteLine("Label MouseMove")
    Console.WriteLine("Button:  " + e.Button.ToString())
    Console.WriteLine("Clicks:  " + e.Clicks.ToString())
    Console.WriteLine("Delta:  " + e.Delta.ToString())
    Console.WriteLine("X:  " + e.X.ToString())
    Console.WriteLine("Y:  " + e.Y.ToString())
  end sub

  private sub lbl_MouseUp(ByVal sender as object, _
                ByVal e as MouseEventArgs)
    lbl.Text = "MouseUp"
    Console.WriteLine("Label MouseUp")
    Console.WriteLine("Button:  " + e.Button.ToString())
    Console.WriteLine("Clicks:  " + e.Clicks.ToString())
    Console.WriteLine("Delta:  " + e.Delta.ToString())
    Console.WriteLine("X:  " + e.X.ToString())
    Console.WriteLine("Y:  " + e.Y.ToString())
  end sub

  private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs)
    lbl.Text = "MouseWheel"
    Console.WriteLine("Label MouseWheel")
    Console.WriteLine("Button:  " + e.Button.ToString())
    Console.WriteLine("Clicks:  " + e.Clicks.ToString())
    Console.WriteLine("Delta:  " + e.Delta.ToString())
    Console.WriteLine("X:  " + e.X.ToString())
    Console.WriteLine("Y:  " + e.Y.ToString())
  end sub

  private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs)
    lbl.Text = "Click"
    Console.WriteLine("Label Click")
  end sub

  private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs)
    lbl.Text = "DoubleClick"
    Console.WriteLine("Label DoubleClick")
  end sub

  protected overrides sub OnMouseEnter(ByVal e as EventArgs)
    myBase.OnMouseEnter(e)
    Console.WriteLine("Form MouseEnter")
  end sub

  protected overrides sub OnMouseHover(ByVal e as EventArgs)
    myBase.OnMouseHover(e)
    Console.WriteLine("Form MouseHover")
  end sub

  protected overrides sub OnMouseLeave(ByVal e as EventArgs)
    myBase.OnMouseLeave(e)
    Console.WriteLine("Form MouseLeave")
  end sub

end class

   
    
  
Related examples in the same category
1.Label.BorderStyle
2.Label.Click
3.Label.DataBindings.Add
4.Label.DoDragDrop
5.Label.DoubleClick
6.Label.DragDrop
7.Label.DragEnter
8.Label.Font.Size
9.Label.Font.Style
10.Label.ForeColor
11.Label.Image
12.Label.ImageAlign
13.Label.ImageIndex
14.Label.ImageList
15.Label.MouseEnter
16.Label.MouseHover
17.Label.MouseLeave
18.Label.MouseMove
19.Label.MouseUp
20.Label.MouseWheel
21.Label.SetBounds
22.Label.Text
23.Label.TextAlign
24.Label.Visible
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.