bonsoir,
j'utilise un datagridview pour afficher mes résultats pour la gestion des alertes.j'ai pu colorer les cellules dont le résultat est zero mais je ne sais pas comment utiliser le timer pour faire clignoter ces cellules!!!![]()
bonsoir,
j'utilise un datagridview pour afficher mes résultats pour la gestion des alertes.j'ai pu colorer les cellules dont le résultat est zero mais je ne sais pas comment utiliser le timer pour faire clignoter ces cellules!!!![]()
bonjour enacta.
C'est facile si le dgv ne comporte pas trop de "lignes visibles" .
Un Timer et une boucle sur les lignes visibles.....avec bien sur la condition de "flashing" (index colonne et valeur de cellule eventuelle).....................
le code:
bon code et bonne annee à tous.....................
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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 'Boite à outils ->Ajouter : '-un control timer '-un bouton '-un dgv de test Public Class Form1 'backcolor par defaut des cellules du dgv Private DefaultCellBackColor As Color Public Sub New() ' Cet appel est requis par le Concepteur Windows Form. InitializeComponent() ' Ajoutez une initialisation quelconque après l'appel InitializeComponent(). 'un bon interval de clignotement Timer1.Interval = 500 Me.Timer1.Enabled = False 'recuperer le backcolor par defaut des cellules du dgv DefaultCellBackColor = Me.DataGridView1.DefaultCellStyle.BackColor End Sub 'Demarrer par exemple le flashing au Load du Form Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Timer1.Start() End Sub 'Cree et Fill un DGV de test Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click AddColorColumn() 'Ajout 10 clients avec compte courant bancaire de 1000.0 à 6000.0 Dim rnd As Random = New Random(0) For I As Integer = 1 To 100 Me.DataGridView1.Rows.Add("Client", 1000.0 * rnd.Next(1, 6), "Rue des Fusilles,Charleroi") Next End Sub Private Sub AddColorColumn() 'Ajout 1ere colonne DataGridViewTextBoxColumn Dim textBoxColumn1 As New DataGridViewTextBoxColumn() textBoxColumn1.Name = "Client" textBoxColumn1.HeaderText = "Client" textBoxColumn1.ValueType = GetType(String) DataGridView1.Columns.Add(textBoxColumn1) 'Ajout 2eme colonne DataGridViewTextBoxColumn Dim textBoxColumn2 As New DataGridViewTextBoxColumn() textBoxColumn1.Name = "Price" textBoxColumn2.HeaderText = "Price" textBoxColumn2.ValueType = GetType(Double) DataGridView1.Columns.Add(textBoxColumn2) 'Ajout 3eme colonne DataGridViewTextBoxColumn Dim textBoxColumn3 As New DataGridViewTextBoxColumn() textBoxColumn1.Name = "Adresse" textBoxColumn2.HeaderText = "Adresse" textBoxColumn2.ValueType = GetType(String) DataGridView1.Columns.Add(textBoxColumn3) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'Si colonne Price ( numero 1) vaut 2000.0 euros =>clignotemment For Each row As DataGridViewRow In Me.DataGridView1.Rows If row.Visible Then If row.Cells(1).Value = 2000.0 Then If row.Cells(1).Style.BackColor = DefaultCellBackColor Then row.Cells(1).Style.BackColor = Color.Red Else row.Cells(1).Style.BackColor = DefaultCellBackColor End If End If End If Next End Sub End Class
Merci bcp MABROUKI pour votre réponseBonne année a vous aussi.
Partager