Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:34:29+00:00 2026-06-02T18:34:29+00:00

I have a form with a CheckedListBox where the user can select multiple options

  • 0

I have a form with a CheckedListBox where the user can select multiple options (it’s filtering down a directory filelist – the filtered files appear in a second listbox).

If I had a set number of options I could use “Or” in the query like this:

Dim query = From f As System.IO.FileInfo In StartList
    Where f.Name.Contains("Romania")
Where f.Channel = "Channel1" Or f.Channel = "Channel2"

But as the person can click any number of options (or none) I can’t do this.
I’ve tried a couple of things including trying to create multiple sub-queries and then performing a Union on them but I can’t get it to work.

This is my code so far:

Dim Channels = ChannelListBox.CheckedItems

    Dim query = From f As System.IO.FileInfo In StartList
    Where f.Name.Contains("Romania")

    If Channels.Count > 0 Then

        Dim CurrentName As String = Channels(0).ToString

        Dim Subquery = From g As System.IO.FileInfo In query
                Where (g.Name.Contains(CurrentName))

        For i = 1 To Channels.Count - 1

            CurrentName = Channels(i).ToString
            Dim Subquery2 = From h As System.IO.FileInfo In query
                                Where (h.Name.Contains(CurrentName))

            Subquery = Subquery.Union(Subquery2)

        Next i

        FileListBox.DataSource = Subquery.ToList

    Else

        FileListBox.DataSource = query.ToList

    End If

Thanks for your help,
Andrew

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:34:31+00:00Added an answer on June 2, 2026 at 6:34 pm
    Dim Channels = ChannelListBox.CheckedItems
    Dim ChannelNames = From c.ToString In Channels
    Dim query = From f As System.IO.FileInfo In StartList
        Where f.Name.Contains("Romania") And ChannelNames.Any(Function(n) f.Name.Contains(n))
    

    I don’t have VB.NET experience, let alone with LINQ, so I hope my syntax is correct. Here’s what I would write in C#:

    var channels = ChannelListBox.CheckedItems;
    var channelNames = channels.Select(c => c.ToString());
    var query = from f in StartList.Cast<System.IO.FileInfo>()
        where f.Name.Contains("Romania") && channelNames.Any(n => f.Name.Contains(n))
        select f;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form, where user selects Airport and then can select one of airport
I' have form that user can select a color. I'm writing that color to
I have form where user submits field. Field can have letters, numbers, and punctuation.
I have form, where some fields are looks like rows, so I can add/delete
I have form with multiple input type=radio with text next to them. I want
i have form with user data to input and javascript ajax to send information
I have: form.input :duration, as: select, collection: {} I need: <option value= data-price=XXX></option> Rails
I have a form containing a checkedlistbox, I want to be able to do
I have form fields where the user enters in: percents: 50.5% money: $144.99 dates:
I have form who validate user input, I use PHP, Javascript and AJAX. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.