I have a set of 2 ComboBoxes i would like to make Combobox 2 not populate from the directory if Combobox1 has a certain character in the file that is highlighted. If at all posible id like to find a way to have it continully search for the specific set of characters in combobox 1 and if the text falls within then combobox 2 will no longer populate

Heres the code im using to populate the Comboboxes

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Files() As String = System.IO.Directory.GetFiles("I:\backuprouter\")
        For Each s As String In System.IO.Directory.GetFiles("I:\backuprouter\")
            ComboBox1A.Items.Add(IO.Path.GetFileName(s))
            ComboBox2A.Items.Add(IO.Path.GetFileName(s))
        Next


        Dim fltr As New ArrayList
        Dim fltr1 As New ArrayList
        Dim opt As System.Text.RegularExpressions.RegexOptions = System.Text.RegularExpressions.RegexOptions.IgnoreCase
        'Add all filenames starting with CE
        For Each file As String In Files
            Dim basename1 As String = My.Computer.FileSystem.GetFileInfo(file).Name
            If System.Text.RegularExpressions.Regex.IsMatch(basename1, "^CE.*", opt) Then
                fltr.Add(basename1)
            End If
        Next
        ComboBox1B.DataSource = fltr
        ComboBox1B.SelectedItem = Nothing

        'Add all filenames starting with BE
        For Each file As String In Files
            Dim basename As String = My.Computer.FileSystem.GetFileInfo(file).Name
            If System.Text.RegularExpressions.Regex.IsMatch(basename, "^BE.*", opt) Then
                fltr1.Add(basename)
            End If
        Next
        ComboBox2B.DataSource = fltr1
        ComboBox2B.SelectedItem = Nothing


    End Sub

Im really new at this but thanks for the help in advance!!!

Edited 1 Year Ago by pritaeas: Moved.

This article has been dead for over six months. Start a new discussion instead.