Solved

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

Posted on 2007-03-28
2
180 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
2 Comments
 
LVL 85

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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