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. Overriding events in an inherited Control

Overriding events in an inherited Control

Scheduled Pinned Locked Moved Visual Basic
question
2 Posts 2 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.
  • S Offline
    S Offline
    Sam Marrocco
    wrote on last edited by
    #1

    I've created a Custom Control that inherits a PictureBox control. When a TestApp uses my newly created custom control, I'd like to add some additional data to the MouseMove event that is returned. Currently the raised event would appear in the TestApp as.... Private Sub MyCustomControl_MouseMove(sender as object, e as MouseEventArgs) handles MyCustomControl.MouseMove My first thought was to add additional arguments such as.... Private Sub MyCustomControl_MouseMove(sender as object, e as MouseEventArgs, MyExtraArgument as double) handles MyCustomControl.MouseMove or as an alternative, add my extra argument to the MouseEventArgs class so it would appear as... e.MyExtraArgument Is either of these methods possible? I'm under the impression that these events/objects may not be overridden without being able to modify the original source code of the parent control. Are there any simple examples of doing either of these techniques? Ideally I'd like to keep all the code within my newly created control library so that the TestApp doesn't require anything other than dropping the newly created child control into it.

    M 1 Reply Last reply
    0
    • S Sam Marrocco

      I've created a Custom Control that inherits a PictureBox control. When a TestApp uses my newly created custom control, I'd like to add some additional data to the MouseMove event that is returned. Currently the raised event would appear in the TestApp as.... Private Sub MyCustomControl_MouseMove(sender as object, e as MouseEventArgs) handles MyCustomControl.MouseMove My first thought was to add additional arguments such as.... Private Sub MyCustomControl_MouseMove(sender as object, e as MouseEventArgs, MyExtraArgument as double) handles MyCustomControl.MouseMove or as an alternative, add my extra argument to the MouseEventArgs class so it would appear as... e.MyExtraArgument Is either of these methods possible? I'm under the impression that these events/objects may not be overridden without being able to modify the original source code of the parent control. Are there any simple examples of doing either of these techniques? Ideally I'd like to keep all the code within my newly created control library so that the TestApp doesn't require anything other than dropping the newly created child control into it.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      You should be adding your arguments as additional e MouseEventArgs so you conform to the existing structures. Google tossed up this article Step by Step: Event handling in C#[^] when I searched for overload event arguments.

      Never underestimate the power of human stupidity RAH

      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