mercredi 30 mars 2016

Capture and Prevent Checkbox un/check in DataGridView from being toggled automatically

I have a datagridview with a column checkbox enter image description here

What i want is if a checkbox click (i use CellContentClick Event) I want show a messageBox that if user press ok .. then checkbox is checked and new query start. Else press Annul or Close Messagebox -> unchecked checkbox .

But i have a problem to implements..

   private void dgvApprovazione_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        try
        {

            if (dgvApprovazione.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewCheckBoxCell)
            {
                CheckBox checkboxTmp = sender as CheckBox;

                checkboxTmp.AutoCheck = false;


            }


        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

EDIT--- I haven't access to design windows. Checkbox is a dinamyc column that is result of read DB. Fields in DB is a true/false type .. In datagridview i have checkbox with check or uncheck .

I want capture and prevent autocheck in 'code-time'




Aucun commentaire:

Enregistrer un commentaire