Checkbox Check C #

-1

I have the following code:

private void lsvRecebeGrupoLayout_ItemChecked(object sender, ItemCheckedEventArgs e)
{
    Layout lay = new Layout();
    GrupoLayout grupo = new GrupoLayout();
    RepositorioLayout repolay = new RepositorioLayout();

    int idcbo = Convert.ToInt32(cboCarregaGrupo.SelectedValue);

    foreach (ListViewItem x in lsvRecebeGrupoLayout.CheckedItems)
    {
        int idlayout = Convert.ToInt32(x.SubItems[0].Text);
        lay = repolay.ConsultaPorId(idlayout);
        grupo.Id = idcbo;
        lay.GrupoLayout = grupo;
        repolay.Alterar(lay);
    }
} 

This code checks a checkbox generated in a list view in C # windows forms, if this check is clicked it does an action to insert a given in a bank table. My question is how could I do it so that when I clicked on it again, I could insert new actions. Thanks.

    
asked by anonymous 06.10.2017 / 21:04

1 answer

0
private void ListView1_ItemCheck1(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
    if (e.CurrentValue==CheckState.Unchecked)
    {
        price += Double.Parse(
            this.ListView1.Items[e.Index].SubItems[1].Text);
    }
    else if((e.CurrentValue==CheckState.Checked))
    {
        price -= Double.Parse(
            this.ListView1.Items[e.Index].SubItems[1].Text);
    }

    // Output the price to TextBox1.
    TextBox1.Text = price.ToString();
}

Source: link

    
06.10.2017 / 21:19