Mein Code sieht so aus:
Aber gesucht wird nur der exakt eingegebene Text bzw Item. Wie krieg ich das hin, dass er nach 2..3 Anfangsbuchstaben , alle ähnlichen Ergebnisse in der Listbox anzeigt, in Echtzeit und ohne Button?
Visual Basic-Quellcode
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim OFD As New OpenFileDialog
- OFD.Multiselect = True
- OFD.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"
- If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
- For Each File As String In OFD.FileNames
- Dim F As New MyFile(File)
- ListBox1.Items.Add(F)
- Next
- End If
- End Sub
- Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
- Try
- Dim SelectedFile As MyFile = DirectCast(ListBox1.SelectedItems(0), MyFile)
- PictureBox1.BackgroundImage = Image.FromFile(SelectedFile.FullName)
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- ListBox1.HorizontalScrollbar = True 'scrollbar
- End Sub
- Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
- For x As Integer = 0 To ListBox1.Items.Count - 1
- If ListBox1.Items(x).ToString = TextBox1.Text$ Then
- ListBox1.SelectedIndex = x
- Return
- End If
- Next
- End Sub
- End Class
- Class MyFile
- Public Property FullName As String
- Public Property ShortName As String
- Public Overrides Function ToString() As String
- Return ShortName
- End Function
- Sub New(ByVal FilePath As String)
- Me.FullName = FilePath
- Me.ShortName = IO.Path.GetFileNameWithoutExtension(FilePath)
- End Sub
- End Class
Aber gesucht wird nur der exakt eingegebene Text bzw Item. Wie krieg ich das hin, dass er nach 2..3 Anfangsbuchstaben , alle ähnlichen Ergebnisse in der Listbox anzeigt, in Echtzeit und ohne Button?