Results 1 to 4 of 4

Thread: [RESOLVED] programatically click a label

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,965

    Resolved [RESOLVED] programatically click a label

    How can I programatically click a label? It has a Click event but no PerformClick method. Thanks...

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: programatically click a label

    Call the event handler directly? Or move the contents of the click event to its own method and call that.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,965

    Re: programatically click a label

    Quote Originally Posted by techgnome View Post
    Call the event handler directly?
    -tg
    yeah, I thought of that right after I posted. doh!

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] programatically click a label

    What tg is referring to is this:

    Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Label1_Click(Nothing, Nothing)
        End Sub
    
        Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    
        End Sub
    However, what I would suggest is that you take the work that you are doing in the click event, and put that into it's own method, and call that method from both places, i.e.:

    Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            MyMethod()
        End Sub
    
        Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
            MyMethod()
        End Sub
    
        Private Sub MyMethod()
    
        End Sub
    Hope that makes sense!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width