Hello,
Sur un formulaire, j'ai 2 DataGridView avec chacun leur propre contenu. Il y a juste 2 colonnes identiques entre les deux. Une nommée "dgvcListType" contenant un String ou Nothing et une autre nommée "dgvcBrowse" contenant un bouton.
Si la colonne dgvcListType vaut Nothing, alors la ligne doit être colorée et le bouton doit être désactivé. Cela fonctionne très bien pour un DataGridView mais pas du tout pour l'autre et je m'en arrache les poils du menton... (pour le peu que j'ai en plus )
Ci-dessous, les deux procédures gérant le changement de couleur des lignes. La première fait son job mais, apparemment, pas la seconde.
J'ai fait du debug pas à pas et ça on passe bien, lors de l'affectation de la propriété DataSource, dans la (2e) procédure.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 Private Sub dgvPromoDetailDemo_DataSourceChanged(sender As Object, e As EventArgs) Handles dgvPromoDetailDemo.DataSourceChanged For Each row As DataGridViewRow In dgvPromoDetailDemo.Rows If row.Cells("dgvcListType").Value Is Nothing Then row.DefaultCellStyle.BackColor = Color.LightGreen CType(row.Cells("dgvcBrowse"), DataGridViewDisableButtonCell).Enabled = False End If Next End Sub Private Sub dgvPromoDetailOwn_DataSourceChanged(sender As Object, e As EventArgs) Handles dgvPromoDetailOwn.DataSourceChanged For Each row As DataGridViewRow In dgvPromoDetailOwn.Rows If row.Cells("dgvcListType").Value Is Nothing Then row.DefaultCellStyle.BackColor = Color.LightGreen CType(row.Cells("dgvcBrowse"), DataGridViewDisableButtonCell).Enabled = False End If Next End Sub
Je ne comprends donc pas pourquoi les lignes ne sont pas mises en vert clair...
Voici l'affectation des propriétés DataSource des deux DataGridView :
Y a-t-il quelque chose de suspect ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Private Sub DisplayDemos() Me.dgvPromoDetailDemo.DataSource = Me.Promo.DTO.DetailsDemo End Sub Private Sub DisplayOwns() Me.Promo.DTO.DetailsOwn = Me.Promo.DTO.DetailsOwn.OrderBy(Function(x) x.Department.Code).ThenBy(Function(x) x.Brand.Code).ThenBy(Function(x) x.SeasonsRange).ToList Me.dgvPromoDetailOwn.DataSource = Me.Promo.DTO.DetailsOwn End Sub
Si quelqu'un avait ne fut-ce qu'une piste, ça m'avancerait.
Merci d'avance.
Partager