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. C#
  4. Custom Event Handler Problem.

Custom Event Handler Problem.

Scheduled Pinned Locked Moved C#
helptutorialquestion
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.
  • H Offline
    H Offline
    hdv212
    wrote on last edited by
    #1

    Hi i want to extend MouseEventArgs class to add some property and info by define new class as follow : namespace CustomEventHandler { public delegate void MouseMoveExEvent(object sender, MouseMoveExEventArgs e); public class MouseMoveExEventArgs : System.Windows.Forms.MouseEventArgs { Point m_mapScrollPos; public MouseMoveExEventArgs(Point mapScrollPosition) { this.m_mapScrollPos = mapScrollPosition; } public Point MapScrollPosition { get { return this.m_mapScrollPos; } } } } as you can see in above code, my class inherited from MouseEventArgs class, but when i compile my app, the following error has shown me : No overload for method 'MouseEventArgs' takes '0' arguments how to solve my problem ? thanks.

    G A 2 Replies Last reply
    0
    • H hdv212

      Hi i want to extend MouseEventArgs class to add some property and info by define new class as follow : namespace CustomEventHandler { public delegate void MouseMoveExEvent(object sender, MouseMoveExEventArgs e); public class MouseMoveExEventArgs : System.Windows.Forms.MouseEventArgs { Point m_mapScrollPos; public MouseMoveExEventArgs(Point mapScrollPosition) { this.m_mapScrollPos = mapScrollPosition; } public Point MapScrollPosition { get { return this.m_mapScrollPos; } } } } as you can see in above code, my class inherited from MouseEventArgs class, but when i compile my app, the following error has shown me : No overload for method 'MouseEventArgs' takes '0' arguments how to solve my problem ? thanks.

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      hdv212, I think the problem is that MouseEventArgs is expecting a constructor that takes no params. So just add:

      public MouseMoveExEventArgs()
      { }

      Regards, Gareth.

      1 Reply Last reply
      0
      • H hdv212

        Hi i want to extend MouseEventArgs class to add some property and info by define new class as follow : namespace CustomEventHandler { public delegate void MouseMoveExEvent(object sender, MouseMoveExEventArgs e); public class MouseMoveExEventArgs : System.Windows.Forms.MouseEventArgs { Point m_mapScrollPos; public MouseMoveExEventArgs(Point mapScrollPosition) { this.m_mapScrollPos = mapScrollPosition; } public Point MapScrollPosition { get { return this.m_mapScrollPos; } } } } as you can see in above code, my class inherited from MouseEventArgs class, but when i compile my app, the following error has shown me : No overload for method 'MouseEventArgs' takes '0' arguments how to solve my problem ? thanks.

        A Offline
        A Offline
        amargujrathi2006
        wrote on last edited by
        #3

        If you want to add new constructor in derived class, there should be exact match of constructor in base class with same parameter. If not then there you have to make call of base class constructor explicitly . So here i have made call to base constructor as following arguments, you can change it. public MouseMoveExEventArgs(Point mapScrollPosition) : base(MouseButtons.Left, 1, mapScrollPosition.X, mapScrollPosition.Y, 2) Hope it will helpful Regards Amar

        H 1 Reply Last reply
        0
        • A amargujrathi2006

          If you want to add new constructor in derived class, there should be exact match of constructor in base class with same parameter. If not then there you have to make call of base class constructor explicitly . So here i have made call to base constructor as following arguments, you can change it. public MouseMoveExEventArgs(Point mapScrollPosition) : base(MouseButtons.Left, 1, mapScrollPosition.X, mapScrollPosition.Y, 2) Hope it will helpful Regards Amar

          H Offline
          H Offline
          hdv212
          wrote on last edited by
          #4

          thanks does you know an helpful article about Custome Event Handler ? thanks

          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