How to add Click and MouseHover events evet to control. Control creates at run time.

Posted on 2006-04-12
Last Modified: 2010-08-05
Here is what I’m been doing

Imports System
Imports System.Windows.Forms
Imports System.Drawing

Public Class Form1
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Call newPic(Me)
    End Sub

    Sub newPic(ByVal form As Windows.Forms.Form)
        Dim pic As New System.Windows.Forms.PictureBox
        pic.Location = New Drawing.Point(10, 10)
        pic.Size = New Drawing.Size(40, 25)
        pic.BackColor = Color.AliceBlue
        pic.BorderStyle = BorderStyle.Fixed3D


    End Sub

End Class

The problem is, I have no events control for this pictureBox
I realy wish to have Click and MouseHover events, for each control.

Please help.
Question by:bogdem
    1 Comment
    LVL 96

    Accepted Solution


    AddHandler pic.Click, AddressOf PicClickHandler

    Private Sub PicClickHandler(ByVal sender As Object, ByVal e As EventArgs)
    End Sub


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now