p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VS.NET 2002/2003 (http://p2p.wrox.com/forumdisplay.php?f=103)
-   -   Event handling in c# (http://p2p.wrox.com/showthread.php?t=55014)

bhavna March 7th, 2007 01:56 AM

Event handling in c#
 

I have a class MyDataGrid which is inherited from Datagrid
which have two protected override functions.
i want to register the events.
for example
public class MyDataGrid : DataGrid

    {
        protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
    {
//dosomething
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
//dosomething
}
Now i want to register these events
i m registering as
this.dataGrid1.MouseDown+=new System.Windows.Forms.MouseEventHandler(this.OnMous eDown);
this.dataGrid1.MouseMove+=new System.Windows.Forms.MouseEventHandler(this.OnMous eMove);

error is
 Method 'System.Windows.Forms.Control.OnMouseDown(System.W indows.Forms.MouseEventArgs)' does not match delegate 'void System.Windows.Forms.MouseEventHandler(object, System.Windows.Forms.MouseEventArgs)'
 Method 'System.Windows.Forms.Control.OnMouseMove(System.W indows.Forms.MouseEventArgs)' does not match delegate 'void System.Windows.Forms.MouseEventHandler(object, System.Windows.Forms.MouseEventArgs)'
can anybody tell me waht's the solution?
i m coding in C# Windows application ,version 1.1(2003)


rodmcleay March 7th, 2007 12:19 PM

This problem would be better in a different forum catagory like C#.
I beleive the error is telling you exactly what the problem is at any rate.
Your methods do not match the delegate you are subscribing to.
Change you method signature to match the delegate.
That is your method must have two paramters, the object and the event args.
protected override void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {//do something}



======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================


All times are GMT -4. The time now is 11:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.