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