VB.Net/GUI/GUI Event

Материал из VB Эксперт
Перейти к: навигация, поиск

Add window message to a ListBox

Imports System
Imports System.Windows.Forms
public class MainClass
   Shared Sub Main()
      Dim form1 As Form = New Form1
      Application.Run(form1)
   End Sub
End Class
Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents listBox1 As System.Windows.Forms.ListBox
    Friend WithEvents button1 As System.Windows.Forms.Button
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.listBox1 = New System.Windows.Forms.ListBox()
        Me.button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        "
        "listBox1
        "
        Me.listBox1.Location = New System.Drawing.Point(8, 8)
        Me.listBox1.Name = "listBox1"
        Me.listBox1.Size = New System.Drawing.Size(272, 212)
        Me.listBox1.TabIndex = 0
        "
        "button1
        "
        Me.button1.Location = New System.Drawing.Point(184, 232)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(96, 32)
        Me.button1.TabIndex = 1
        Me.button1.Text = "Clear"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button1, Me.listBox1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
    End Sub
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        listBox1().Items.Clear()
    End Sub

    Protected Overrides Sub wndproc(ByRef m As Message)
        Select Case m.Msg
            Case &H20, &H84
                " Ignore WM_SETCURSOR, WM_NCHITTEST
                " Because there are so many of them
            Case Else
                listBox1().Items.Add(m.ToString)
        End Select
        MyBase.WndProc(m)
    End Sub
#End Region
End Class


Form and Control Click Event

Imports System
Imports System.Drawing
Imports System.Windows.Forms
public class MainClass
   Shared Sub Main()
      Dim form1 As Form = New Form1
      Application.Run(form1)
   End Sub
End Class

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents ctl1 As System.Windows.Forms.Control
    Friend WithEvents textBox1 As System.Windows.Forms.TextBox
    Friend WithEvents textBox2 As System.Windows.Forms.TextBox
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.ctl1 = New System.Windows.Forms.Control()
        Me.textBox1 = New System.Windows.Forms.TextBox()
        Me.textBox2 = New System.Windows.Forms.TextBox()
        Me.ctl1.SuspendLayout()
        Me.SuspendLayout()
        "
        "ctl1
        "
        Me.ctl1.BackColor = System.Drawing.Color.Bisque
        Me.ctl1.Controls.AddRange(New System.Windows.Forms.Control() {Me.textBox1})
        Me.ctl1.Name = "ctl1"
        Me.ctl1.Size = New System.Drawing.Size(128, 112)
        Me.ctl1.TabIndex = 0
        "
        "textBox1
        "
        Me.textBox1.Location = New System.Drawing.Point(32, 48)
        Me.textBox1.Name = "textBox1"
        Me.textBox1.Size = New System.Drawing.Size(72, 20)
        Me.textBox1.TabIndex = 1
        Me.textBox1.Text = "textBox1"
        "
        "textBox2
        "
        Me.textBox2.Location = New System.Drawing.Point(24, 128)
        Me.textBox2.Name = "textBox2"
        Me.textBox2.Size = New System.Drawing.Size(96, 20)
        Me.textBox2.TabIndex = 1
        Me.textBox2.Text = "textBox2"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.textBox2, Me.ctl1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ctl1.ResumeLayout(False)
        Me.ResumeLayout(False)
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
#End Region
    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
        Console.WriteLine(Me.ClientRectangle.ToString)
    End Sub
    Private Sub ctl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctl1.Click
        Console.WriteLine(ctl1().ClientRectangle.ToString)
    
    End Sub
End Class


Handle more than one events

Imports System
Imports System.Drawing
Imports System.Reflection
Imports System.Windows.Forms
Imports System.IO

public class MainClass
   Shared Sub Main()
      Dim form1 As Form = New Form1
      Application.Run(form1)
   End Sub
End Class

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code"
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.Container
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    Friend WithEvents Red As System.Windows.Forms.MenuItem
    Friend WithEvents Green As System.Windows.Forms.MenuItem
    Friend WithEvents Blue As System.Windows.Forms.MenuItem
    Friend WithEvents Yellow As System.Windows.Forms.MenuItem
    Friend WithEvents Black As System.Windows.Forms.MenuItem
    Friend WithEvents White As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    Friend WithEvents AlignLeft As System.Windows.Forms.MenuItem
    Friend WithEvents AlignCenter As System.Windows.Forms.MenuItem
    Friend WithEvents AlignRight As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.MainMenu1 = New System.Windows.Forms.MainMenu()
        Me.MenuItem1 = New System.Windows.Forms.MenuItem()
        Me.Red = New System.Windows.Forms.MenuItem()
        Me.Green = New System.Windows.Forms.MenuItem()
        Me.Blue = New System.Windows.Forms.MenuItem()
        Me.Yellow = New System.Windows.Forms.MenuItem()
        Me.Black = New System.Windows.Forms.MenuItem()
        Me.White = New System.Windows.Forms.MenuItem()
        Me.MenuItem2 = New System.Windows.Forms.MenuItem()
        Me.AlignLeft = New System.Windows.Forms.MenuItem()
        Me.AlignCenter = New System.Windows.Forms.MenuItem()
        Me.AlignRight = New System.Windows.Forms.MenuItem()
        "
        "MainMenu1
        "
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2})
        "
        "MenuItem1
        "
        Me.MenuItem1.Index = 0
        Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.Red, Me.Green, Me.Blue, Me.Yellow, Me.Black, Me.White})
        Me.MenuItem1.Text = "Color"
        "
        "Red
        "
        Me.Red.Index = 0
        Me.Red.OwnerDraw = True
        Me.Red.Text = ""
        "
        "Green
        "
        Me.Green.Index = 1
        Me.Green.OwnerDraw = True
        Me.Green.Text = ""
        "
        "Blue
        "
        Me.Blue.Index = 2
        Me.Blue.OwnerDraw = True
        Me.Blue.Text = ""
        "
        "Yellow
        "
        Me.Yellow.Index = 3
        Me.Yellow.OwnerDraw = True
        Me.Yellow.Text = ""
        "
        "Black
        "
        Me.Black.Index = 4
        Me.Black.OwnerDraw = True
        Me.Black.Text = ""
        "
        "White
        "
        Me.White.Index = 5
        Me.White.OwnerDraw = True
        Me.White.Text = ""
        "
        "MenuItem2
        "
        Me.MenuItem2.Index = 1
        Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.AlignLeft, Me.AlignCenter, Me.AlignRight})
        Me.MenuItem2.Text = "Alignment"
        "
        "AlignLeft
        "
        Me.AlignLeft.Index = 0
        Me.AlignLeft.OwnerDraw = True
        Me.AlignLeft.Text = "Left"
        "
        "AlignCenter
        "
        Me.AlignCenter.Index = 1
        Me.AlignCenter.OwnerDraw = True
        Me.AlignCenter.Text = "Center"
        "
        "AlignRight
        "
        Me.AlignRight.Index = 2
        Me.AlignRight.OwnerDraw = True
        Me.AlignRight.Text = "Right"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 129)
        Me.Menu = Me.MainMenu1
        Me.Name = "Form1"
        Me.Text = "Owner-Drawn Menu"
    End Sub
#End Region
    Dim currentFont As Font
    Private Sub Red_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Red.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        e.Graphics.FillRectangle(Brushes.Red, R)
    End Sub
    Private Sub Red_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles Red.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(80, 18)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub Green_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles Red.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(80, 18)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub Green_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Green.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        e.Graphics.FillRectangle(Brushes.Green, R)
    End Sub
    Private Sub Blue_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles Blue.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(80, 18)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub Blue_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Blue.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        e.Graphics.FillRectangle(Brushes.Blue, R)
    End Sub
    Private Sub Yellow_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles Yellow.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(80, 18)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub Yellow_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Yellow.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        e.Graphics.FillRectangle(Brushes.Yellow, R)
    End Sub
    Private Sub White_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles White.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(80, 18)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub White_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles White.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        e.Graphics.FillRectangle(Brushes.White, R)
    End Sub
    Private Sub Black_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles Black.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(80, 18)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub Black_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Black.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        e.Graphics.FillRectangle(Brushes.Black, R)
    End Sub
    Private Sub AlignLeft_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles AlignLeft.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(40, 14)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub AlignLeft_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles AlignLeft.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        Dim strfmt As New StringFormat()
        strfmt.Alignment = StringAlignment.Near
        e.Graphics.DrawString("Left", Me.Font, Brushes.Black, R, strfmt)
    End Sub
    Private Sub AlignRight_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles AlignRight.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(40, 14)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub AlignRight_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles AlignRight.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        Dim strfmt As New StringFormat()
        strfmt.Alignment = StringAlignment.Far
        e.Graphics.DrawString("Right", Me.Font, Brushes.Black, R, strfmt)
    End Sub
    Private Sub AlignCenter_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles AlignCenter.MeasureItem
        Dim itemSize As SizeF
        itemSize = New SizeF(40, 14)
        e.ItemHeight = itemSize.Height
        e.ItemWidth = itemSize.Width
    End Sub
    Private Sub AlignCenter_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles AlignCenter.DrawItem
        Dim R As New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)
        Dim strfmt As New StringFormat()
        strfmt.Alignment = StringAlignment.Center
        e.Graphics.DrawString("Center", Me.Font, Brushes.Black, R, strfmt)
    End Sub

    Private Sub Alignment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlignCenter.Click, AlignLeft.Click, AlignRight.Click,Red.Click,Green.Click,Blue.Click,Yellow.Click,Black.Click,White.Click
        MessageBox.Show(sender.Text)
    End Sub
End Class


Log UI event

Imports System
Imports System.Windows.Forms

Public Class MainClass
    
    Shared Sub Main()
        Dim form1 As Form = New Form1
        Application.Run(form1)

    End Sub
End Class
Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txt As System.Windows.Forms.TextBox
    Friend WithEvents pic As System.Windows.Forms.PictureBox
    Friend WithEvents lstLog As System.Windows.Forms.ListBox
    Friend WithEvents cmd As System.Windows.Forms.Button
    Friend WithEvents Label3 As System.Windows.Forms.Label
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.Container
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.txt = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.lstLog = New System.Windows.Forms.ListBox()
        Me.pic = New System.Windows.Forms.PictureBox()
        Me.cmd = New System.Windows.Forms.Button()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        "
        "txt
        "
        Me.txt.Location = New System.Drawing.Point(156, 20)
        Me.txt.Name = "txt"
        Me.txt.Size = New System.Drawing.Size(192, 21)
        Me.txt.TabIndex = 1
        Me.txt.Text = ""
        "
        "Label1
        "
        Me.Label1.Location = New System.Drawing.Point(6, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(144, 16)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Test keyboard events here:"
        "
        "Label2
        "
        Me.Label2.Location = New System.Drawing.Point(20, 52)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(128, 16)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "Test mouse events here:"
        "
        "lstLog
        "
        Me.lstLog.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.lstLog.IntegralHeight = False
        Me.lstLog.Location = New System.Drawing.Point(8, 160)
        Me.lstLog.Name = "lstLog"
        Me.lstLog.Size = New System.Drawing.Size(384, 212)
        Me.lstLog.TabIndex = 0
        "
        "pic
        "
        Me.pic.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.pic.Location = New System.Drawing.Point(156, 48)
        Me.pic.Name = "pic"
        Me.pic.Size = New System.Drawing.Size(192, 48)
        Me.pic.TabIndex = 3
        Me.pic.TabStop = False
        "
        "cmd
        "
        Me.cmd.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.cmd.Location = New System.Drawing.Point(156, 100)
        Me.cmd.Name = "cmd"
        Me.cmd.Size = New System.Drawing.Size(88, 28)
        Me.cmd.TabIndex = 4
        Me.cmd.Text = "Button1"
        "
        "Label3
        "
        Me.Label3.Location = New System.Drawing.Point(24, 104)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(64, 24)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "Label3"
        "
        "GroupBox1
        "
        Me.GroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label4, Me.Label1, Me.pic, Me.txt, Me.cmd, Me.Label2})
        Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.GroupBox1.Location = New System.Drawing.Point(8, 4)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(384, 148)
        Me.GroupBox1.TabIndex = 6
        Me.GroupBox1.TabStop = False
        "
        "Label4
        "
        Me.Label4.Location = New System.Drawing.Point(92, 108)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(56, 16)
        Me.Label4.TabIndex = 5
        Me.Label4.Text = "And here:"
        "
        "Form1
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
        Me.ClientSize = New System.Drawing.Size(400, 378)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.Label3, Me.lstLog})
        Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Name = "Form1"
        Me.Text = "Event Tracker"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)
    End Sub
#End Region

    Private Sub txt_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt.KeyDown
        AddEventToListBox("Key Down: " & e.KeyCode & e.KeyValue)
    End Sub
    Private Sub txt_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt.KeyUp
        AddEventToListBox("Key Up: " & e.KeyCode & e.KeyValue & " Text is: " & txt.Text)
    End Sub
    Private Sub txt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt.TextChanged
        AddEventToListBox("Changed: " & " Text is: " & txt.Text)
    End Sub

    Private Sub txt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt.KeyPress
        AddEventToListBox("Key Press: " & e.KeyChar)
    End Sub
    Private Sub pic_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles pic.MouseEnter, cmd.MouseEnter
        AddEventToListBox("Mouse Enter")
    End Sub
    Private Sub pic_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseMove
        AddEventToListBox("Mouse Move: ") 
    End Sub
    Private Sub pic_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles pic.MouseHover, cmd.MouseHover
        AddEventToListBox("Mouse Hover")
    End Sub
    Private Sub pic_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseDown, cmd.MouseDown
        AddEventToListBox("Mouse Down: X=" & e.X & "Y=" & e.Y & " Button=" & e.Button.ToString)
    End Sub
    Private Sub pic_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseUp, cmd.MouseUp
        AddEventToListBox("Mouse Up: X=" & e.X & "Y=" & e.Y & " Button=" & e.Button.ToString)
    End Sub
    Private Sub pic_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles pic.Click, cmd.Click
        AddEventToListBox("Click")
    End Sub
    Private Sub pic_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles pic.DoubleClick
        AddEventToListBox("Double Click")
    End Sub
    Private Sub pic_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles pic.MouseLeave
        AddEventToListBox("Mouse Leave")
    End Sub

    Private Sub AddEventToListBox(ByVal data As String)
        lstLog.Items.Add(data)
    End Sub
End Class