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

In .NET land, there's the tremendously useful System.Windows.Forms.CheckedListBox class. What is the equivalent in
I'm using wxPython to create a GUI app. Right now I'm using a wx.CheckListBox
I would like to create a custom wizard page after the page where you
I have a DataBound CheckedListBox, I need to check some items on it. I
I want to use a CheckedListBox in an application where each item in the
SQL Tables Listing ID, Title..... ListingType ID, Name ListingMatrix ListingID, ListingTypeID Basically a listing
I have a c# winform application (2008) with datagridview bound to data from sqlserver.
The WinForms CheckedListBox control has 2 default behaviors when clicking with a mouse: In
i've added a checkbox to a checkedlistbox using the following code: CheckBox cb =
I have an instance of System.Windows.Forms.CheckedListBox which displays a list of tick boxes and

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.