Results 1 to 6 of 6

Thread: Call Click Event

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Call Click Event

    How can I call the Click even of a button from somewhere else in code?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Call Click Event

    vb Code:
    1. button1.performclick

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Re: Call Click Event

    Thanks. Is it the same for other controls too, like the PictureBox?
    What about other evens like DoubleClick?
    How is this different from the RaiseEvent word?

  4. #4
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Call Click Event

    RaiseEvent can only be used on class events that are not inherited.
    For other events, you could try calling the event handler:
    Code:
    PictureBox1_DoubleClick(Me.PictureBox1,EventArgs.Empty)

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Call Click Event

    Calling the event handler isn't a good idea IMHO... if the control has a click event that can be handled, use the .PerformClick method. If you are performing actions in a click event of something that could be called outside of that click event, then perhaps that code should be in a sub that CAN be called directly, and then the event handler calls that sub.

    -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??? *

  6. #6
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Call Click Event

    Why ever not? Besides, that's for the DoubleClick, etc. events.

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