Gent.mi,
questa volta gradirei gentilmente un Vostro gradito aiuto per risolvere il seguente problema:
in un DataGridView, contiene 4 colonne: Nome, Cognome, Città e Via.
Gradirei effettuare una ricerca dei dati sulla prima colonna (Nome) tramite una TextBox avendo la possibilità di nascondere le voci non interessate.
Il DataGrid, viene popolato tramite un button che legge i dati precedentemente salvati sul desktop con estensione ".TXT".
Inserito nella TextBox una lettera di una voce, con il seguente codice riesco ad evidenziare tutta la riga.
[CODEPrivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim righe As Integer = 0
Dim colonne As Integer = 0
righe = Me.DataGridView1.RowCount
colonne = Me.DataGridView1.ColumnCount
Dim IndiceRighe As Integer = 0
Dim IndiceColonne As Integer = 0
For Each Riga As DataGridViewRow In DataGridView1.Rows
If String.IsNullOrEmpty(Riga.Cells(0).Value) = False Or String.IsNullOrEmpty(Riga.Cells(1).Value) = False _
Or String.IsNullOrEmpty(Riga.Cells(2).Value) = False Or String.IsNullOrEmpty(Riga.Cells(3).Value) = False Then
Dim stringa As String = Riga.Cells(0).Value.ToString
If stringa.IndexOf(TextBox1.Text) = 0 Then
DataGridView1(0, Riga.Index).Style.BackColor = Color.Aquamarine
DataGridView1(1, Riga.Index).Style.BackColor = Color.Aquamarine
DataGridView1(2, Riga.Index).Style.BackColor = Color.Aquamarine
DataGridView1(3, Riga.Index).Style.BackColor = Color.Aquamarine
End If
End If
Next
End Sub
Ho inserito il codice con un risultato negativo:
' Dim SearchQuery As String = "SELECT * From Users WHERE CONCAT(fname, lname, age) like '%" & TextBox1.Text & "%'"][/CODE]
Fiducioso di una gradita, saluto.
Domenico.