c# eventhandling error

Go To StackoverFlow.com

-1

i have method

private void getValues(object sender, EventArgs e)
    {
        int id = int.Parse(dgvTable.Rows[dgvTable.CurrentRow.Index].Cells[0].Value.ToString());
        var values = from c in v.db.TotalDoc
                     where c.TotalID == id
                     select c.TotalAmount;
        dgvValues.DataSource = values;
    }

and datagridview "dgvTable" error at this line

dgvTable.CellClick += new EventHadler(getValues);

error text is: No overload for 'getValues' matches delegate 'System.EventHandler'

please help!

2012-04-05 17:23
by bragin.www


2

The DataGridView.CellClick method signature is a DataGridViewCellEventHandler and not of type EventHandler. Change your method signature to this:

private void getValues(object sender, DataGridViewCellEventArgs e)

and also change your declaration to this:

dgvTable.CellClick += new DataGridViewCellEventHandler(getValues);
2012-04-05 17:26
by Bryan Crosby
private void getValues(object sender, DataGridViewCellEventArgs e) - the same error. doesn't work - bragin.www 2012-04-05 17:28
@bragin.www: you need to also change your declaration as wel - Bryan Crosby 2012-04-05 17:29
one more question. error disappeared but event have no effect after calling the CellClick() method of the dgv. may be i should add some more code - bragin.www 2012-04-05 17:50
@bragin.www: I would actually just post another question. It's better than re-editing and re-answering - Bryan Crosby 2012-04-05 17:52
http://stackoverflow.com/questions/10033609/c-sharp-datagridview-cellclick-method-doesnt-wor - bragin.www 2012-04-05 18:05


2

private void getValues(object sender, DataGridViewCellEventArgs e)
2012-04-05 17:26
by Raphaël Althaus
Ads