Solved

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

Posted on 2007-03-28
2
177 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Handling arrays 14 34
help with issues with ReportViewer in VS2015 5 24
Hide Tab Page 3 20
Format column on datatable 7 18
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

19 Experts available now in Live!

Get 1:1 Help Now