Solved

SelectionMode on a CheckedListBox

Posted on 2004-10-14
3
390 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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