Bonjour a tous,
je tourne un peu en rond...
j'aimerais une piste pour filtrer un datagridview par le texte sélectionné dans un combobox déclenché par un bouton. le tableau est au préalable rempli par une base CSV (pour raison de compatibillitée des // postes de travail).
j'ai cherché mais tout ce que j'ai trouvé c'est par BDD, moi c'est un fichier CSV qui sera stocké sur un serveur.
ci-dessous le code :
appel de la fonction import:
import.ImportDonnees("D:\fichier choix moteur\BASE DONNEE.csv")
remplissage des données dans le tableau:
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
|
Imports System.IO
Module import
Public Sub ImportDonnees(ByVal StrFile As String)
Dim sr As StreamReader = New StreamReader(StrFile, System.Text.Encoding.Default)
Dim Str As String
Dim Cpt As Integer = 0
Dim Delim As Char = ";"
Dim SubChaine() As String
Dim NbLine, NbCol As Long
Form1.DataGridView1.Rows.Clear()
Do Until sr.Peek = -1
Str = sr.ReadLine()
'Nbre Colonnes
If Cpt = 0 Then
For A As Integer = 1 To Len(Str)
If Mid(Str, A, 1) = Delim Then
NbCol += 1
System.Windows.Forms.Application.DoEvents()
End If
Next A
Form1.DataGridView1.ColumnCount = NbCol + 1
Cpt = 1
End If
'Remplir DataGridView
SubChaine = Str.Split(Delim)
Form1.DataGridView1.Rows.Add(SubChaine)
System.Windows.Forms.Application.DoEvents()
NbLine += 1
Loop
End Sub
End Module |
Merci de votre aide.
Partager