Datagridview checkboxcell disfonctionnement
Bonjour a tous,
Voila je m'arrache les cheveux(j'en ais deja plus bcp) avec les datagridcheckboxcell qui je trouve ne fonctionne pas bien du tous.
voila mon problème:
j'ai un datagridview avec des datagridcheckboxcolumn
quand je check une case, je souhaite que toutes mes cases de la colonne se check
comme je trouve qu'il ne fonctionne pas très bien j'ai crée un evenement
qui fait ceci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| else if (data.Rows[e.RowIndex].Cells[e.ColumnIndex].GetType() == typeof(DataGridViewCheckBoxCell))
{
string i = data.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
if (i == "1")
for (int t = 0; t < data.RowCount; t++)
{
DataGridViewCheckBoxCell dc = new DataGridViewCheckBoxCell();
//dc = data.Rows[t].Cells[e.ColumnIndex];
data.Rows[t].Cells[e.ColumnIndex].Value = 0;
}
else
{
for (int t = 0; t < data.RowCount; t++)
{
data.Rows[t].Cells[e.ColumnIndex].Value = 1;
}
}
} |
le problème, c'est si je check juste a coté de la case, toutes les autre se check sauf celle ci alors que ca valeur est bien a 1 bizard
( j'ai rajouter aussi
Code:
1 2
| datacheck.FalseValue = 0;
datacheck.TrueValue = 1; |
deuxieme problème, lorsque je clique plusieurs fois rapidement sur les checkbox, ca me fait un meli melo.
2 question:
Comment puis-je resoudre ces problèmes,
Comment puis-je tester
Code:
if (data.Rows[j].Cells[i].Value == true)
qui ne marche pas bien sur
ni même
Code:
data.Rows[j].Cells[i].Value.tostring() == "true"
merci beaucoup a tous et surtout bonne journée :-)