Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I am working on user Control. In that user COntrol , I want to add Some New events for access from the form(Parent form).
I added New Events for CellClicked and CellDoubleClick.
Here the Code,
C#
//Declaration 
 public delegate void CellClickedEventHandler(object sender, DataGridViewCellEventArgs e);
 public event CellClickedEventHandler CellClicked;

 public delegate void CellDoubleClickedEventHandler(object sender, DataGridViewCellEventArgs e);
 public event CellDoubleClickedEventHandler CellDoubleClicked;


//Functions
  private void CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (CellClicked != null)
                CellClicked(this, e);
        } 

  private void CellDouClick(object sender, DataGridViewCellEventArgs e)
        {
            if (CellDoubleClicked != null)
                CellDoubleClicked(this, e);
        }

On the Constructor:
C#
<datagridview name="">.CellClick += new DataGridViewCellEventHandler(CellClicked);
<datagridview name="">.CellDoubleClick += new DataGridViewCellEventHandler(CellDoubleClicked);

Rebuild the application. no error displayed on the Error List

Drag the User Control(Datagridview), I am getting following error.
Quote:
Delegate to an instance method cannot have null 'this'

How can i solve this?
Posted
Updated 23-Jul-14 2:10am
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900