Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am able to create my labels with the image passed, but i want to add an event that if the user clicks on the label it displays a message box or loads another form, something like that.

 

This is what I have, and its not even close to working. :confused:

 

Private Sub addlabel(ByVal myImage As Bitmap)
       Static num As Integer
       Dim ctl As Control
       num += 1
       ReDim TextBoxes(num)
       TextBoxes(num - 1) = New MyLabel
       With TextBoxes(num - 1)
           .Size = myImage.Size
           .Location = New System.Drawing.Point(10, num * (.Height + 10))
           .Image = myImage
           AddHandler (ctl, Labels_Click)
       End With

       TabPage1.Controls.Add(TextBoxes(num - 1))

   End Sub


   Public Sub Labels_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Labels_Click.Click

       MsgBox(Me.Name, "clicked")
   End Sub

Posted

ok this will compile but will not show the label that i am creating

 

i think that the problem lies somewhere with the: Handles MyBase.Click

 

Private Sub addlabel(ByVal myImage As Bitmap)
       Static num As Integer
       Dim size As Integer
       size = myImage.Height + 25
       Dim ctl As Control
       num += 1
       ReDim TextBoxes(num)
       TextBoxes(num - 1) = New MyLabel
       With TextBoxes(num - 1)
           .Size = myImage.Size
           .Height = size
           .Text = "test"
           .Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
           .TextAlign = ContentAlignment.BottomCenter
           .Location = New System.Drawing.Point(10, num * (.Height + 10))
           .Image = myImage
           AddHandler ctl.Click, AddressOf Labels_Click
       End With

       TabPage1.Controls.Add(TextBoxes(num - 1))

   End Sub


   Public Sub Labels_Click(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Click
       MsgBox(Me.Name, "clicked")
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...