Fórum Marcar Vários CheckBox #507483
16/01/2015
0
Gostaria de criar um botão que marque vários checkbox em um gridview, em windows form C#, já tentei estes códigos abaixo, mas nenhum marca.
Alguem sabe como ?
Alguem sabe como ?
private void BtnMarcar_Click(object sender, EventArgs e)
{
this.itemLocacaoDataGridView.Cells["Devolver"].Value = true;
}
private void BtnMarcar_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow grid in itemLocacaoDataGridView.Rows)
{
(grid.Cells["Devolver"]. as DataGridViewCheckBoxCell).Value = true;
}
}
private void BtnMarcar_Click(object sender, EventArgs e)
{
for(int i = 0; i < this.Controls.Count; i++)
{
if(this.Controls[i] is System.Windows.Forms.CheckBox)
{
(this.Controls[i] as CheckBox).Checked = true;
}
}
}
private void BtnMarcar_Click(object sender, EventArgs e)
{
CheckBox check;
foreach(GridViewRow grid in itemLocacaoDataGridView.Rows)
{
check = (CheckBox)grid.Cells["Devolver"].Controls[0];
check.Checked = true;
}
}
Jair Souza
Curtir tópico
+ 0
Responder
Posts
20/01/2015
Joel Rodrigues
Veja se este tópico lhe ajuda: Check/Uncheck a checkbox on datagridview.
Responder
Gostei + 0
27/01/2015
Jair Souza
Para desmarcar funcionou e ficou assim :
Mas para marcar não estou conseguindo ajustar....
private void BtnDesMarcar_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in itemLocacaoDataGridView.Rows)
{
DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells["Devolver"];
if (chk.Value == chk.TrueValue || chk.Value != null)
{
chk.Value = chk.FalseValue;
}
itemLocacaoDataGridView.EndEdit();
}
}Mas para marcar não estou conseguindo ajustar....
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)