Overload Error C#

Asked

Viewed 43 times

0

I am experiencing the following CS0123 error No Overload for 'lsvRecebeGrupoLayout_ItemCheck' Matches delegate 'Itemcheckeventhandler' in the code below, any suggestions what might be causing this error?

private void lsvRecebeGrupoLayout_ItemCheck(object sender, ItemCheckEventArgs e, CheckBox cb)
{
    GrupoLayout gp = new GrupoLayout();
    RepositorioGrupoLayout r = new RepositorioGrupoLayout();
    Layout lay = new Layout();
    cb.Checked = Convert.ToBoolean(gp.Id);
    lay.Id = Convert.ToInt32(cb.Checked);
    r.Alterar(lay.GrupoLayout);

}

1 answer

3


This happens because your lsvRecebeGrupoLayout_ItemCheck is a method whose signature is not valid to be an event Handler ItemCheck.

According to the specification, the method signature shall contain only object and ItemCheckEventArgs

How to solve?

Remove the Checkbox cb signature. You don’t need it there, because it is yours sender, just cast a:

var cb = (CheckBox)sender;

  • killed the mistake, thank you very much Artur. #PAZ

  • @Anderson, if the answer has met well, mark it as accepted ;)

  • I was waiting for time to run out :)

  • I’m trying to get an ID from a checkbox in the list view, but I’m not getting it, taking advantage of the cue. Any tips on how to do this? the Code looks like this: private void lsvRecebeGrupoLayout_ItemCheck(Object Sender, Itemcheckeventargs and) { var cb = (Checkbox)Sender; Grupolayout gp = new Grupolayout(); Repositoriogrupolayout r = new Repositoriogrupolayout(); Layout lay = new Layout(); if (cb.Checked) { cb.Checked = Convert.Toboolean(gp.Id); lay.Id = Convert.Toint32(cb.Checked); . Change(lay.Grupolayout); } }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.