Bonjour,
Je sais que le sujet a déjà été traité ( cf : http://www.developpez.net/forums/d32...pprimer-ligne/) mais je pense ou trouve que ce n'est pas fait proprement.
Je m'explique quand j'efface une ligne a avec cette méthode tous fonctionne bien. Mais j'ai aussi une fonction qui permet de recharger la flexgrid avec un tableau enregistrer dans un fichier, et quand j'efface une ligne et que ensuite je charge un tableau théoriquement le tableau s'efface et charge le fichier. mais si avant de charger j'efface une ligne le chargement ne se fais pas correctement.
Exemple :
Le fichier comporte un tableau a trois lignes je le charge
flexgrid affiche les 3 lignes
je supprime un ligne du tableau
le tableau ne comporte plus que 2 lignes
je recharge le fichier qui comporte toujours un tableau a 3 lignes
la flexgrid en affiche que 2
Et la si je clique un peu en dessous de la dernière ligne je vois que elle contient des données mais qui sont invisible dirons nous ...
Je peux fournir pour ceux qui veulent l'executable et le fichier de configuration ( le tous pèse même pas 200ko de mémoire )
Voici le code de la fonction supprime :
Celui de la fonction de chargement :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub CmdSupP_Click() If (MSHFlexGridSsLiB.Row = 0) Then A = MsgBox("Impossible de supprimer la ligne", vbCritical, "Erreur") Else MSHFlexGridSsLiB.RemoveItem MSHFlexGridSsLiB.Row TxtPlibCh.Text = "" TxtPInV.Text = "" TxtPInC.Text = "" MSHFlexGridSsLiB.AddItem MSHFlexGridSsLiB.Row ' MSHFlexGridSsLiB.Rows = MSHFlexGridSsLiB.Rows - 1 End If End Sub
Et celui de la flexgrid je sais pas si ca peut aider mais bon :
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 Private Sub Cmdload_Click() Dim adresse As String Dim i As Double Dim ligne As String Dim nb As Double Dim tb() As String Dim tot As Double Dim compt As Integer CmDial.ShowOpen adresse = CmDial.FileName If (CmDial.FileName = Empty) Then Else If Dir(adresse, vbNormal) = "" Then A = MsgBox("vous avez choisie un fichier qui n'existe pas", vbExclamation) Exit Sub End If While Not MSHFlexGrid1.Rows = 1 MSHFlexGrid1.Rows = MSHFlexGrid1.Rows - 1 'Pour ajouter une ligne à l grille Wend While Not MSHFlexGridSsLiB.Rows = 1 MSHFlexGridSsLiB.Rows = MSHFlexGridSsLiB.Rows - 1 'Pour ajouter une ligne à l grille Wend Open adresse For Input As #1 CmDial.FileName = Empty compt = 0 On Error GoTo 4 While Not EOF(1) Input #1, ligne ligne = Trim(ligne) tb = Split(ligne, "\") tot = 0 i = 0 'MsgBox ligne 'MsgBox compt If compt = 0 Then ' restitue la parametre de boucle + indexcol Form1.txtboucle.Text = ligne 'i=1 compt = compt + 1 ElseIf compt = 1 Then Form1.Txtindexcol.Text = ligne compt = 3 End If ' ' For i = 0 To UBound(tb) ' TEST ' If tb(i) = Empty Then ' Else ' MsgBox tb(i) ' ' End If 'Next If (tb(i) = "1//") Then 'ajout d'un item For i = 0 To UBound(tb) If (tb(i) <> Empty) Then If (i = 0) Then 'rien faire car c'est le flag Else Form1.MSHFlexGridSsLiB.TextMatrix(MSHFlexGridSsLiB.Rows - 1, tot) = tb(i) tot = tot + 1 If (tot = 3) Then 'si colonne est 3 MSHFlexGridSsLiB.Rows = MSHFlexGridSsLiB.Rows + 1 End If End If End If Next ElseIf (tb(i) = "2//") Then 'ajout item For i = 0 To UBound(tb) If (tb(i) <> Empty) Then If (i = 0) Then 'rien faire car c'est le flag Else Form1.MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Rows - 1, tot) = tb(i) tot = tot + 1 If (tot = 4) Then 'si colonne est 4 MSHFlexGrid1.Rows = MSHFlexGrid1.Rows + 1 End If End If End If Next End If Wend MSHFlexGrid1.Rows = MSHFlexGrid1.Rows - 1 'annule la derniere ligne ajouté MSHFlexGridSsLiB.Rows = MSHFlexGridSsLiB.Rows - 1 Close #1 End If 4: End Sub
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
82
83
84
85
86
87
88 Private Sub MSHFlexGridSsLiB_Click() Dim ligne As Integer Dim temp As Integer ligne = 1 temp = MSHFlexGridSsLiB.Row While (ligne <= (MSHFlexGridSsLiB.Rows - 1)) ' init le tableau a blanc MSHFlexGridSsLiB.Row = ligne MSHFlexGridSsLiB.Col = 0 MSHFlexGridSsLiB.CellBackColor = vbWhite MSHFlexGridSsLiB.Col = 1 MSHFlexGridSsLiB.CellBackColor = vbWhite MSHFlexGridSsLiB.Col = 2 MSHFlexGridSsLiB.CellBackColor = vbWhite ligne = ligne + 1 Wend MSHFlexGridSsLiB.Row = temp If (MSHFlexGridSsLiB.Row = 0) Then ' A = MsgBox("Impossible de selectionner cette ligne", vbExclamation, "") ElseIf (MSHFlexGridSsLiB.Col = 0) Then MSHFlexGridSsLiB.Col = 0 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 1 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 2 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 0 Form1.TxtPlibCh.Text = MSHFlexGridSsLiB.Text MSHFlexGridSsLiB.Col = MSHFlexGridSsLiB.Col + 1 Form1.TxtPInV.Text = MSHFlexGridSsLiB.Text MSHFlexGridSsLiB.Col = MSHFlexGridSsLiB.Col + 1 Form1.TxtPInC.Text = MSHFlexGridSsLiB.Text ElseIf (MSHFlexGridSsLiB.Col = 1) Then MSHFlexGridSsLiB.Col = 0 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 1 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 2 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 1 Form1.TxtPInV.Text = MSHFlexGridSsLiB.Text MSHFlexGridSsLiB.Col = MSHFlexGridSsLiB.Col + 1 Form1.TxtPInC.Text = MSHFlexGridSsLiB.Text MSHFlexGridSsLiB.Col = MSHFlexGridSsLiB.Col - 2 Form1.TxtPlibCh.Text = MSHFlexGridSsLiB.Text ElseIf (MSHFlexGridSsLiB.Col = 2) Then MSHFlexGridSsLiB.Col = 0 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 1 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 2 MSHFlexGridSsLiB.CellBackColor = COLOR MSHFlexGridSsLiB.Col = 2 Form1.TxtPInC.Text = MSHFlexGridSsLiB.Text MSHFlexGridSsLiB.Col = MSHFlexGridSsLiB.Col - 1 Form1.TxtPInV.Text = MSHFlexGridSsLiB.Text MSHFlexGridSsLiB.Col = MSHFlexGridSsLiB.Col - 1 Form1.TxtPlibCh.Text = MSHFlexGridSsLiB.Text End If End Sub
J'espere avoir ete clair et je vous souhaite a tous une bonne journée et/ou un bon Week end
Je rappelle que toutes les critiques sur ma façon de coder sont les bienvenue
Over
Partager