Dobrý večer, prosím o pomoc. Hľadám v tabulke "Album2" výrax "Text=xyz". Ak existuje tak riadok zapisujem do "ListBoxu" všetko je OK. ListBox som nahradil DataGridView1 a už mi zapíše len posledný výskyt. Používam VB2005 Express.
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Static n As Integer = 0
If e.KeyCode = Keys.Enter Then
Dim text As String
text = TextBox1.Text.ToLower
'List.Items.Clear()
For i As Integer = 0 To Album2DataGridView.RowCount - 1
For j As Integer = 2 To 3
If Album2DataGridView.Rows(i).Cells(j).Value Is Nothing Then Album2DataGridView.Rows(i).Cells(j).Value = ""
If System.Convert.ToString(Album2DataGridView.Rows(i).Cells(j).Value).ToLower.IndexOf(TextBox1.Text.ToLower) > -1 Then
'Dim polozka As New ListViewItem()
'polozka.Text = Album2DataGridView.Rows(i).Cells(0).Value
'polozka.SubItems.Add(Album2DataGridView.Rows(i).Cells(1).Value)
'polozka.SubItems.Add(Album2DataGridView.Rows(i).Cells(2).Value)
'If Album2DataGridView.Rows(i).Cells(3).Value Is Nothing Then Album2DataGridView.Rows(i).Cells(3).Value = ""
'polozka.SubItems.Add(Album2DataGridView.Rows(i).Cells(3).Value)
'List.Items.Add(polozka)
For k As Integer = 0 To 3
DataGridView1.Rows(n).Cells(k).Value = Album2DataGridView.Rows(i).Cells(k).Value
Next
DataGridView1.Rows.Add()
n += 1
Exit For
End If
Next j
Next i
Panel1.Visible = True
End If
End Sub
|