AddHandler and AddressOf : AddressOf « Event « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Event » AddressOf 
11.3.3.AddHandler and AddressOf
AddHandler and AddressOf
Option Strict On
imports System
imports System.Drawing
imports System.Windows.Forms

public class MouseEnterHoverLeave : inherits Form

  private btn as Button

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

    btn = new Button()
    btn.Parent = me
    btn.Location = new Point(50,50)
    btn.Size = new Size(150,25)
    AddHandler btn.MouseEnter, AddressOf btn_MouseEnter
    AddHandler btn.MouseHover, AddressOf btn_MouseHover
    AddHandler btn.MouseLeave, AddressOf btn_MouseLeave
  end sub

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

  private sub btn_MouseEnter(ByVal sender as object,ByVal e as EventArgs)
    btn.Text = "MouseEnter"
    Console.WriteLine("Button MouseEnter")
  end sub

  private sub btn_MouseHover(ByVal sender as object,ByVal e as EventArgs)
    btn.Text = "MouseHover"
    Console.WriteLine("Button MouseHover")
  end sub

  private sub btn_MouseLeave(ByVal sender as object,ByVal e as EventArgs)
    btn.Text = "MouseLeave"
    Console.WriteLine("Button MouseLeave")
  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
11.3.AddressOf
11.3.1.AddressOf operator
11.3.2.Use EventHandler with AddressOf
11.3.3.AddHandler and AddressOfAddHandler and AddressOf
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.