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

  • SEARCH
  • Home
  • 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 776329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:25:43+00:00 2026-05-14T19:25:43+00:00

With the CheckListBox in VB.NET in VS2005, how would you make it compulsory that

  • 0

With the CheckListBox in VB.NET in VS2005, how would you make it compulsory that at least one item is selected?

Can you select one of the items at design time to make it the default?

What would be best way to handle the validation part of this scenario? When should the user be required to tick one of the boxes?

  • 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-05-14T19:25:44+00:00Added an answer on May 14, 2026 at 7:25 pm

    Either idea — preventing the user from unchecking the last checked item, or validating that at least one item is checked before proceeding — is fairly straightforward to implement.

    How to prevent the user from unchecking the last checked item

    1. Make sure at least one item is checked to begin with (e.g., in your form’s Load event):

    Private Sub frm_Load(ByVal sender As Object, ByVal e As EventArgs)
        clb.SetItemChecked(0, True) ' whatever index you want as your default '
    End Sub
    

    2. Add some simple logic to your ItemCheck event handler:

    Private Sub clb_ItemCheck(ByVal sender As Object, ByVal e As ItemCheckEventArgs)
        If clb.CheckedItems.Count = 1 Then ' only one item is still checked... '
            If e.CurrentValue = CheckState.Checked Then ' ...and this is it... '
                e.NewValue = CheckState.Checked ' ...so keep it checked '
            End If
        End If
    End Sub
    

    How to validate that at least one item is checked

    Private Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' you could also put the below in its own method '
        If clb.CheckedItems.Count < 1 Then
            MsgBox("You must check at least one item.")
            Return
        End If
    
        ' do whatever you need to do '
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add checked items from one checklistbox to another. I should not
I have a CheckedListBox. I would like to be able to select items when
i created a class derived from CheckedListBox so i can change item height as
How can I bind my object collection to CheckedListBox items with IsChecked property? Here
I'm writing an windforms application using .NET (actually IronPython, but that's not relevant), and
I'm shopping around for a dropdown list control that allows me to select multiple
In .NET framework, is it possible to set some of the items in the
I've got a log file that can contain the same event (Verification) multiple times,
I have a CheckedListBox, and I want to automatically tick one of the items
When an item is clicked in the checkedlistbox, it gets highlighted. How can 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.