Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SelectionMode on a CheckedListBox

Posted on 2004-10-14
3
Medium Priority
?
392 Views
Last Modified: 2009-07-29
The SelectionMode.One on a Checked List Box DOES NOT WORK! I've read the MSDN Instructions, and it does nothing. You can still select as many check boxes as you want ..anyone have a workaround for this?
0
Comment
Question by:derekthornton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 12312012
SelectoinMode is something else. In a checked list box you can CHECK the items and also SELECT the items. The SelectionMode says that only one item can be selected, but multiple can be checked.

You can use the ItemCheck event to manually disable multiple checks. The event is described here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscheckedlistboxclassitemchecktopic.asp
0
 
LVL 3

Accepted Solution

by:
aacool earned 2000 total points
ID: 12312978
Here is code that solves your problem:

private void checkedListBox1_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
   SelectionMode mode = checkedListBox1.SelectionMode;
  if(mode == SelectionMode.One)
 {
    //uncheck all other items
    foreach(int i in checkedListBox1.CheckedIndices)
   {
      if(i!=e.Index)
      {
                checkedListBox1.SetItemCheckState(i,CheckState.Unchecked);            
      }
   }
}
                        
            }
0
 
LVL 1

Expert Comment

by:Kahhoe
ID: 12315793
If you want only one item to be checked, I suggest you to use radio buttons..
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question