Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Checkbox


This question is answered.


Permlink Replies: 8 - Last Post: May 19, 2017 10:19 PM Last Post By: Melissa Torn
Melissa Torn

Posts: 143
Registered: 4/30/09
Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 18, 2017 10:57 PM
I have more than 1 checkboxes in my form
if i click one of them i want ( in just 1 click )
1-Checked=True (clicked checkbox)
2- Uncheck ALL the other checkboxes if it is checked

Thank you
Olivier Sannier

Posts: 424
Registered: 8/26/01
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 18, 2017 11:43 PM   in response to: Melissa Torn in response to: Melissa Torn
Melissa Torn wrote:
I have more than 1 checkboxes in my form
if i click one of them i want ( in just 1 click )
1-Checked=True (clicked checkbox)
2- Uncheck ALL the other checkboxes if it is checked

Thank you

That's what radio buttons are for.
Melissa Torn

Posts: 143
Registered: 4/30/09
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 18, 2017 11:53 PM   in response to: Olivier Sannier in response to: Olivier Sannier
Thank you Olivier,
but i need to use Checkbox
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: Checkbox
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2017 1:02 AM   in response to: Melissa Torn in response to: Melissa Torn
El 19/05/2017 a las 08:53, Melissa Torn escribió:
Thank you Olivier,
but i need to use Checkbox

1) Add the following "Working" variable to the private section of your
form declaration:

   ...
   private
     { Private declarations }
     Working: Boolean;
   ...


2) Add an OnClick event to one of the check box components:
procedure TForm21.CheckBox1Click(Sender: TObject);
var
  i: Integer;
  Ctrl: TComponent;
begin
  if not Working then
  begin
    Working := True;
    for i := 0 to ComponentCount-1 do
    begin
      Ctrl := Components[i];
      if (Ctrl is TCheckBox) and (Ctrl<> Sender) then
        (Ctrl as TCheckBox).Checked := False;
    end;
    Working := False;
  end;
end;


3) Assign this OnClick event to all others check boxes.
Olivier Sannier

Posts: 424
Registered: 8/26/01
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2017 1:04 AM   in response to: Melissa Torn in response to: Melissa Torn
Melissa Torn wrote:
Thank you Olivier,
but i need to use Checkbox

Well, there's a conceptual issue here.
I mean radio buttons have a look to convey the idea that they are
mutually exclusive.
The same goes for checkboxes where they convey the idea that you can
select them independently.

Now, you want to have checkboxes that behave like radio buttons, and
while this can be achieved easily, I find it to be extremely confusing
for end users.
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2017 1:22 AM   in response to: Olivier Sannier in response to: Olivier Sannier
Olivier Sannier wrote:

Melissa Torn wrote:
Thank you Olivier,
but i need to use Checkbox

Well, there's a conceptual issue here.
I mean radio buttons have a look to convey the idea that they are
mutually exclusive.
The same goes for checkboxes where they convey the idea that you can
select them independently.

Exactly.

Now, you want to have checkboxes that behave like radio buttons, and
while this can be achieved easily, I find it to be extremely
confusing for end users.

Indeed. And using radio buttons would be much easier as well.

--
Rudy Velthuis http://www.rvelthuis.de

"The public is wonderfully tolerant. It forgives everything
except genius."
-- Oscar Wilde
Alex Belo

Posts: 626
Registered: 10/8/06
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2017 10:25 AM   in response to: Olivier Sannier in response to: Olivier Sannier
Olivier Sannier wrote:

while this can be achieved easily, I find it to be extremely
confusing for end users.

The task looks as homework so "end user" (teacher) will not be confused
too much.

;-)

--
Alex
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2017 1:56 AM   in response to: Melissa Torn in response to: Melissa Torn
Melissa Torn wrote:

Thank you Olivier,
but i need to use Checkbox

Do you really, or do you think so? As Olivier said, it makes no good
sense to make checkboxes behave like radiobuttons.

--
Rudy Velthuis http://www.rvelthuis.de

"Always remember you are a totally unique individual; just like
everyone else."
-- Unknown
Melissa Torn

Posts: 143
Registered: 4/30/09
Re: Checkbox  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2017 10:19 PM   in response to: Melissa Torn in response to: Melissa Torn
Thank you Antonio and eveybody

Dont worry, i will not use checkbox instead of
Radio Button this was just an idea and wondered
how i can do that. That is all
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02