cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 2019
-
23 sept. 2013 à 12:54
cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 2019
-
24 sept. 2013 à 11:19
Bonjour,
J'ai un datagridview contenant n colonnes (n = 4 par ex )
j'ajoute 10 rangées
For i as integer = 0 to 9
DataGridView2.Rows.Add()
Next
je voudrais après l'evenement DataGridView2_CellClick
changer la couleur de la cellule en question
j'ai écrit
Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
If e.ColumnIndex < 0 Or e.RowIndex < 0 Then
Exit Sub
End If
DataGridView2.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = Color.LemonChiffon
End Sub
cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 201957 24 sept. 2013 à 10:45
Salut Moundir76
ça marche ainsi la cellule que tu cliques passe en surbrillance donc on ne voit pas la modification de la couleur seulement si on clique une autre cellule on pourra voir la modification de la précedente cellule
si on veut supprimer la surbrillance
Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick
If e.ColumnIndex < 0 Or e.RowIndex < 0 Then
Exit Sub
End If
DataGridView2.ClearSelection()
'blabla
end sub