Results 1 to 6 of 6

Thread: VB.NET Perform DoubleClick on Label

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2021
    Posts
    191

    VB.NET Perform DoubleClick on Label

    Hi All - I have a form with 20-30 labels on it that I am using to trigger some other events when the label is double-clicked. It all worked fine until someone asked how a barcode scan could work along side double clicking the label directly on the computer screen. I am trying to wrap my head around this but cannot figure out exactly what I need to make this happen. So for now, I have tried creating a textbox to allow input of a barcode scan. If the scanned barcode in the text field is (in my case) "Test 1 Warning" on LostFocus then I am calling my label doubleclick event like this:

    Code:
    Test1_Warning_DoubleClick(Nothing, Nothing)
    Trying to create this as if I was physically doubleclicking the label. I can get somewhat where I want to be, but my code will not run from my Label DoubleClick event. So my question is, how can I enter something to a textbox and have that mimic the physical doubleclick event?

    Thanks

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: VB.NET Perform DoubleClick on Label

    Why you have to mimic double click?
    A scanner will usually send the enter or if it is programmable (by barcode commands) any special character you set it.
    Also have a look here:
    https://www.vbforums.com/showthread....hlight=barcode
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    Junior Member
    Join Date
    Oct 2017
    Posts
    21

    Re: VB.NET Perform DoubleClick on Label

    Your problem description is hard to comprehend.
    It reads to me as if your Label_DoubleClick code worked fine until you now try to call the event handler of the Label_DoubleClick from a Textbox_LostFocus, which also works but broke your original Label_DoubleClick handler. - Which makes little sense to me.

    Quote Originally Posted by mikeg71 View Post
    So my question is, how can I enter something to a textbox and have that mimic the physical doubleclick event?
    Usually, you don't.
    Instead you write a dedicated procedure to do the actual work (process the barcode?), then call this procedure from the event handler (Label_DoubleClick).
    If you need to run the same code from a different event (the new Textbox_LostFocus event handler), you simply call the very same procedure instead of messing with other event handlers.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: VB.NET Perform DoubleClick on Label

    I agree with what sonic8 said. Calling a method is just calling a method. Calling it from two different places won't cause one to stop working, unless you changed that method by some means. At a guess, I'd say that you moved something around and lost the Handles clause on the Double Click event handler, but that's nothing more than a guess.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2021
    Posts
    191

    Re: VB.NET Perform DoubleClick on Label

    Thanks all for the replies. Basically, (Shaggy Hiker) was correct. I had changed a few things and got myself lost. It all seems to be working ok now. Thanks for your time

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB.NET Perform DoubleClick on Label

    Please use the Thread Tools menu to mark your thread Resolved. That way, we can see that you no longer need help without opening the thread and reading the whole thing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

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