Solved

Trying to pass user created image.tag to another forms textbox

Posted on 2007-03-28
2
184 Views
Last Modified: 2010-04-23
Hi

Using VB.Net VS 2003

I am just getting into public subs and how they work. I have some code where a user has created an image on the tab of a form - Form2. I am trying to put an event handler behind the image for when it is clicked so it will pass the Image.Tag value to a textbox on Form13.

Here is what I have thus far:

Dim tabAttImg As New PictureBox
tabAttImg.Image = clsGlobals.Form2.ImageList1.Images(0)
tabAttImg.Name = "pic" & txtName.Text
tabAttImg.Tag = txtName.Text
tabAttImg.Cursor = System.Windows.Forms.Cursors.Hand
tabAttImg.Size = New Size(16, 16)
tabAttImg.Location = New Point(208, 8 + (TabbyCt * 24))

AddHandler tabAttImg.Click, AddressOf ListClickster(ByVal sender As System.Object, ByVal e As System.EventArgs) 'this line does not work the ByVal text is causing an error - says expression required

clsGlobals.Form2.TabControl1.SelectedTab.Controls.Add(tabAttImg)


'this is the code I want put in a click event behind the image created above. How do I do this?
Public Sub ListClickster(ByVal ctrl As Control)

        If clsGlobals.Form13 Is Nothing Then
            clsGlobals.Form13 = New Form13
        End If

        clsGlobals.Form13.Show()
        clsGlobals.Form13.Focus()
        clsGlobals.Form13.lblTarget.Text = "Target Attribute: " & ctrl.Tag

    End Sub
0
Comment
Question by:PBLack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 18810823
The sub your are "wiring up" with AddHandler has to have the SAME signature as the event being trapped.

So your ListClickster() sub needs to match the PictureBox.Click() event signature.

Also, in the "AddHandler" only the name of the sub goes after the "AddressOf" part...

Something like...

        ...
        AddHandler tabAttImg.Click, AddressOf ListClickster
        ...

    Public Sub ListClickster(ByVal sender As Object, ByVal e As System.EventArgs)
        If clsGlobals.Form13 Is Nothing Then
            clsGlobals.Form13 = New Form13
        End If

        clsGlobals.Form13.Show()
        clsGlobals.Form13.Focus()
        clsGlobals.Form13.lblTarget.Text = "Target Attribute: " & sender.Tag
    End Sub
0
 

Author Comment

by:PBLack
ID: 18810929
thank you - still learning and you helped me move up the curve one more notch

Cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

627 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