Solved

SelectionMode on a CheckedListBox

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses

627 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