Beispiel #1
0
        // fazer a validação para ativar o botão de gerar o lote
        private void ListaNotas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //var selecionar = (DataGridView)sender;
            //selecionar.EndEdit();

            //foreach (DataGridViewRow row in ListaNotas.Rows)
            //{
            //    if (e.RowIndex >= 0)
            //    {
            //        var cbxCell = (DataGridViewCheckBoxCell)selecionar.Rows[e.RowIndex].Cells[0];
            //        if ((bool)cbxCell.Value)
            //       // if (Convert.ToBoolean(cbxCell.Value))
            //        {
            //            button2.Enabled = true;
            //        }
            //        else
            //        {
            //            button2.Enabled = false;
            //        }
            //    }
            //}

            if (e.ColumnIndex == 0 && e.RowIndex > -1)
            {
                ListaNotas.CommitEdit(DataGridViewDataErrorContexts.Commit);
                var i = 0;
                foreach (DataGridViewRow row in ListaNotas.Rows)
                {
                    if (Convert.ToBoolean(row.Cells[0].Value))
                    {
                        i++;
                    }
                }


                if (i > 0)
                {
                    button2.Enabled = true;
                }
                else
                {
                    button2.Enabled = false;
                }
            }
        }