Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Events & Delegates in VB question

Events & Delegates in VB question

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bertvan
    wrote on last edited by
    #1

    Hello, I only recently started working in VB, so now I'm having an obvious syntax-wise question: I want to hook the .Click event of an object (sectionItem), inheriting from Panel to a Sub in my class. In C# this would simply be sectionItem.Click += new EventHandler(mySub) , but in VB I'm a bit confused. Could someone point me to the right actions? Tnx

    _ 1 Reply Last reply
    0
    • B bertvan

      Hello, I only recently started working in VB, so now I'm having an obvious syntax-wise question: I want to hook the .Click event of an object (sectionItem), inheriting from Panel to a Sub in my class. In C# this would simply be sectionItem.Click += new EventHandler(mySub) , but in VB I'm a bit confused. Could someone point me to the right actions? Tnx

      _ Offline
      _ Offline
      _mubashir
      wrote on last edited by
      #2

      you can use AddHandler in VB.NET inorder to bind an event dynamically Like, AddHandler btnClose.Click, AddressOf btnClose_Click where btnClose is a button and btnClose_Click is the function or the event handler for that button when that button is clicked Mubashir

      Every job is a self portrait of the person who did it.

      B D 2 Replies Last reply
      0
      • _ _mubashir

        you can use AddHandler in VB.NET inorder to bind an event dynamically Like, AddHandler btnClose.Click, AddressOf btnClose_Click where btnClose is a button and btnClose_Click is the function or the event handler for that button when that button is clicked Mubashir

        Every job is a self portrait of the person who did it.

        B Offline
        B Offline
        bertvan
        wrote on last edited by
        #3

        Exactly what I needed. Thanks!

        1 Reply Last reply
        0
        • _ _mubashir

          you can use AddHandler in VB.NET inorder to bind an event dynamically Like, AddHandler btnClose.Click, AddressOf btnClose_Click where btnClose is a button and btnClose_Click is the function or the event handler for that button when that button is clicked Mubashir

          Every job is a self portrait of the person who did it.

          D Offline
          D Offline
          Dave Doknjas
          wrote on last edited by
          #4

          There are two options in VB: 1. As described by Mubashir. 2. Using a "Handles" clause: e.g., Public Sub btnClose_Click(......) Handles btnClose.Click Some people prefer this more traditional VB way. However, of course this method only applies to cases that you know at design time.

          David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Instant Python: C# to Python converter, VB to Python converter

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups