473,769 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Only allow one checked checkbox in a collection

Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way of
doing this ?

I dont want to use Radio buttons.....

Thanks,

Jon.

Feb 20 '07 #1
10 18934

Hi,

"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way of
doing this ?

I dont want to use Radio buttons.....

Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by radio
buttons not checkboxes. If you do not follow this rule your interface will
be weird.
You can do what you want by checking the status of the checkboxes, or the
one that is checked, if another is checked you uncheck the first. You may
found a little issue knowing when (the change of status) was induced by
your code or by the user. but figuring this out is the fun part of the thing
:)

Feb 20 '07 #2
Yes, I thought that may be the answer.

Many moons ago when I did a bit of VB4 I thought there was a way of grouping
checkboxs to behave like radio buttons ? Maybe my memory is playing tricks
on me.....

I just wondered if there is the same built in functionailty today ( If there
ever was ! )

Thanks,

Jon.


"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:Oz******** ******@TK2MSFTN GP02.phx.gbl...
>
Hi,

"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
>Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way of
doing this ?

I dont want to use Radio buttons.....


Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by
radio buttons not checkboxes. If you do not follow this rule your
interface will be weird.
You can do what you want by checking the status of the checkboxes, or the
one that is checked, if another is checked you uncheck the first. You may
found a little issue knowing when (the change of status) was induced by
your code or by the user. but figuring this out is the fun part of the
thing :)

Feb 20 '07 #3
Based on your requirements you need to disable or enable check boxes

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>
Hi,

"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way of
doing this ?

I dont want to use Radio buttons.....


Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by radio
buttons not checkboxes. If you do not follow this rule your interface will
be weird.
You can do what you want by checking the status of the checkboxes, or the
one that is checked, if another is checked you uncheck the first. You may
found a little issue knowing when (the change of status) was induced by
your code or by the user. but figuring this out is the fun part of the thing
:)

Feb 20 '07 #4
I dont need to inhibit which checkbox they are selecting, I just need to
only allow one.

The problem is inverse if I use Radio buttons as I will only be able to
select a single Button, when on occasion I may need to select multiple.....

JB
"NRao" <NR**@discussio ns.microsoft.co mwrote in message
news:2A******** *************** ***********@mic rosoft.com...
Based on your requirements you need to disable or enable check boxes

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>>
Hi,

"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8******* *******@TK2MSFT NGP02.phx.gbl.. .
Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way
of
doing this ?

I dont want to use Radio buttons.....


Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by
radio
buttons not checkboxes. If you do not follow this rule your interface
will
be weird.
You can do what you want by checking the status of the checkboxes, or the
one that is checked, if another is checked you uncheck the first. You may
found a little issue knowing when (the change of status) was induced by
your code or by the user. but figuring this out is the fun part of the
thing
:)


Feb 20 '07 #5
You need to ask yourself why you are designing a form that uses the same
control for two unrelated purposes. You probably need two different
controls (a radio group, and a check box group) that you enable at different
times according to the application's requirements.

Just my 2c. YMMV.
Peter
"Bishman" <jo************ *@btinternet.co mwrote in message
news:%2******** *******@TK2MSFT NGP03.phx.gbl.. .
>I dont need to inhibit which checkbox they are selecting, I just need to
only allow one.

The problem is inverse if I use Radio buttons as I will only be able to
select a single Button, when on occasion I may need to select
multiple.....

JB
"NRao" <NR**@discussio ns.microsoft.co mwrote in message
news:2A******** *************** ***********@mic rosoft.com...
>Based on your requirements you need to disable or enable check boxes

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>>>
Hi,

"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8****** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way
of
doing this ?

I dont want to use Radio buttons.....
Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by
radio
buttons not checkboxes. If you do not follow this rule your interface
will
be weird.
You can do what you want by checking the status of the checkboxes, or
the
one that is checked, if another is checked you uncheck the first. You
may
found a little issue knowing when (the change of status) was induced by
your code or by the user. but figuring this out is the fun part of the
thing
:)



Feb 20 '07 #6
Hi,

"NRao" <NR**@discussio ns.microsoft.co mwrote in message
news:2A******** *************** ***********@mic rosoft.com...
Based on your requirements you need to disable or enable check boxes
No really, because if he disable all other checkboxes there is no way to
select them back.

Basically he needs radiobuttons :)
Feb 20 '07 #7
....I think its one of those 'visual' ones !

Thanks for all the responses....
"Peter Bradley" <pb******@uwic. ac.ukwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
You need to ask yourself why you are designing a form that uses the same
control for two unrelated purposes. You probably need two different
controls (a radio group, and a check box group) that you enable at
different times according to the application's requirements.

Just my 2c. YMMV.
Peter
"Bishman" <jo************ *@btinternet.co mwrote in message
news:%2******** *******@TK2MSFT NGP03.phx.gbl.. .
>>I dont need to inhibit which checkbox they are selecting, I just need to
only allow one.

The problem is inverse if I use Radio buttons as I will only be able to
select a single Button, when on occasion I may need to select
multiple.... .

JB
"NRao" <NR**@discussio ns.microsoft.co mwrote in message
news:2A******* *************** ************@mi crosoft.com...
>>Based on your requirements you need to disable or enable check boxes

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8***** *********@TK2MS FTNGP02.phx.gbl ...
Hi,

I need to programmaticall y allow or disallow the selection of
multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a
way of
doing this ?

I dont want to use Radio buttons.....
Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by
radio
buttons not checkboxes. If you do not follow this rule your interface
will
be weird.
You can do what you want by checking the status of the checkboxes, or
the
one that is checked, if another is checked you uncheck the first. You
may
found a little issue knowing when (the change of status) was induced
by
your code or by the user. but figuring this out is the fun part of the
thing
:)




Feb 20 '07 #8
Just create client-side or server-side code to check for how many are checked
whenever one is clicked. If the checked count is 1, make the event sender
unchecked.

Psuedocode:

checkbox_onclic k
{
if (Only1Allowed)
if (sender.checked && anyOtherIsCheck ed())
{
sender.checked = false;
showUserWhy();
}
}
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Bishman" wrote:
Hi,

I need to programmaticall y allow or disallow the selection of multiple
checkboxes on a form . At certain times I only want to allow a single
selection, at other times I may wish to allow multiple. Is there a way of
doing this ?

I dont want to use Radio buttons.....

Thanks,

Jon.

Feb 20 '07 #9
You can always set up an event handler that handles all the checkboxes.
Then when someone checks one and sets it to checked, loop through and
uncheck all the other ones.

Robin S.
--------------------------
"Bishman" <jo************ *@btinternet.co mwrote in message
news:eu******** ******@TK2MSFTN GP02.phx.gbl...
...I think its one of those 'visual' ones !

Thanks for all the responses....
"Peter Bradley" <pb******@uwic. ac.ukwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>You need to ask yourself why you are designing a form that uses the same
control for two unrelated purposes. You probably need two different
controls (a radio group, and a check box group) that you enable at
different times according to the application's requirements.

Just my 2c. YMMV.
Peter
"Bishman" <jo************ *@btinternet.co mwrote in message
news:%2******* ********@TK2MSF TNGP03.phx.gbl. ..
>>>I dont need to inhibit which checkbox they are selecting, I just need to
only allow one.

The problem is inverse if I use Radio buttons as I will only be able to
select a single Button, when on occasion I may need to select
multiple... ..

JB
"NRao" <NR**@discussio ns.microsoft.co mwrote in message
news:2A****** *************** *************@m icrosoft.com...
Based on your requirements you need to disable or enable check boxes

"Ignacio Machin ( .NET/ C# MVP )" wrote:

>
Hi,
>
"Bishman" <jo************ *@btinternet.co mwrote in message
news:O8**** **********@TK2M SFTNGP02.phx.gb l...
Hi,

I need to programmaticall y allow or disallow the selection of
multiple
checkboxes on a form . At certain times I only want to allow a
single
selection, at other times I may wish to allow multiple. Is there a
way of
doing this ?

I dont want to use Radio buttons.....
>
>
Why dont use Radio buttons?
The user expect that a mutually exclusive selection be represented by
radio
buttons not checkboxes. If you do not follow this rule your interface
will
be weird.
>
>
You can do what you want by checking the status of the checkboxes, or
the
one that is checked, if another is checked you uncheck the first. You
may
found a little issue knowing when (the change of status) was induced
by
your code or by the user. but figuring this out is the fun part of
the thing
:)
>
>
>
>




Feb 21 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2551
by: Joel Brabant | last post by:
Hi again, Within a submitted page that has mutilple checkboxes with the same name, the request.form("mycheckboxes") has a comma separated list of the values of all the ones checked.... but I also need to know which ones are not checked... How can I know that ? Thanks.
4
6601
by: Michael Champagne | last post by:
We have an application to where you can select/deselect all checkboxes in a checkbox array by clicking a 'master' checkbox at the top of the screen. This seems to work fine unless there is only one checkbox (these are dynamically generated). Why does this fail? If I do an alert(field_to_check.length) with 1 element in the array like this I get 'Undefined'. Is this because this datatype is not an array if there is only 1 element here? ...
12
2313
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type text,text,radio,checkbox and select. When I run the following code, it correctly reports "text" (for input
2
9209
by: /.. | last post by:
Hi all, I'm working on a report display page that currently uses 5 checkboxlists with a total of 86 items to display values from 5 different tables in an Access database. The page works fine now. On presenting it to the users they pointed out that their users could change the values in the checkboxes and then print them out, ultimately documenting false information.
4
10551
by: moondaddy | last post by:
There are different times when I will have a group of checkboxes and need to force only one to be checked at a time. I would also like to do this client side and not require a postback. These checkboxes could be just a group of check boxes across the top of a page, or could be part of a datalist or datagrid. How do I make it so when a use clicks on one checkbox that if another checkbox is checked, it becomes unchecked? Also, is it...
2
2089
by: Alan Silver | last post by:
Hello, I have a repeater with a list of products in it. Each item in the repeater has a checkbox, allowing the product to be selected. When a link button is clicked, I want to loop through the repeater and handle each product whose checkbox is checked. The repeater looks (greatly chopped down) like this... <asp:Repeater ID="rptProducts" RunAt="Server">
2
1429
by: Wayne Wengert | last post by:
I have an aspx page which contains a datalist, which in turn, is populated with checkboxes based on the contents of a SQL table (see code below). I want a routine to go through all the checkboxes in this set and determine which ones the user checked. I know I've seen some nice tight routines to do this but I had no luck Googling for it. ================== Code ====================== <asp:DataList ID="DataList1" runat="server"...
8
16617
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below the repeater. When clicked, it is supposed to
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.