-3

I have multiple checkboxes (C#) and I want if the user check one checkbox then unckeck all other checkboxes except the last selected,or he can check them all (he must check one or all). I use visual studio C#

GibboK
  • 71,848
  • 143
  • 435
  • 658
Hussein.M
  • 407
  • 1
  • 4
  • 7
  • 4
    Are you using win Forms, WPF or web? – Vincent Hubert May 08 '14 at 13:56
  • Are you building a webforms/mvc/winforms/wpf app? – Ross Bush May 08 '14 at 13:56
  • 1
    why don't you use a radio button list? – Ricardo Appleton May 08 '14 at 13:57
  • @RicardoAppleton, because you cannot check them all – Vincent Hubert May 08 '14 at 13:57
  • What have you tried so far? @RicardoAppleton can't because he wants the user to be able to check all of the options. – Zohar Peled May 08 '14 at 13:57
  • 1
    `if the user check one checkbox`: do you mean 1 very specific checkbox? While the other checkboxes do not uncheck their siblings when you click on them? – Flater May 08 '14 at 13:59
  • post your code. what have you tried so far? – Ricardo Appleton May 08 '14 at 14:00
  • It would help to internally manage an array or list which contains references to the checkboxes in questions. Furthermore events would have to be disabled during assignment of the other checkboxes. – Codor May 08 '14 at 14:01
  • Checkbox is a GUI element in computing that can be used in Windows Forms, WPF, Silverlight, HTML and many other platforms/frameworks. There is nothing specific to C# about it. So first, you need to specify your platform. Also, if your user is allowed to select only one option, then you should be using radio buttons instead of checkboxes. **Edit after you add Visual Studio to the question:** Specifying that you use Visual Studio doesn't provide what kind of application you're developing, because all of the ones I wrote above can be developed in Visual Studio. – Şafak Gür May 08 '14 at 14:03
  • 3
    Checkbox may not be the best UI element for this task. Consider radio buttons or drop down list that contain all values plus an additional value for "All". – Aaron Palmer May 08 '14 at 14:05
  • possible duplicate of [How do I group Windows Form radio buttons?](http://stackoverflow.com/questions/2178240/how-do-i-group-windows-form-radio-buttons) – jww Jul 31 '14 at 09:39

1 Answers1

2

Use RadioBoxes instead, but include an option for "All of the above".

If you don't want to do that then you need to specify your platform you are developing in. Most likely you would add an event handler on the click event and check every box manually to see if it's checked or not.

Paul
  • 5,700
  • 5
  • 43
  • 67