Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to make a CheckBox or Radio Button READONLY

1,114 views
Skip to first unread message

Yosi Taguri

unread,
Aug 18, 1999, 3:00:00 AM8/18/99
to
how can I make it them Readonly without making them Enable:=False

I tried to Add TCustomCheckBox a published Readonly property
wich checks and sets ClicksDisabled ... but it didn't work...

yosi

Steve Zimmelman

unread,
Aug 18, 1999, 3:00:00 AM8/18/99
to
You might want to look at theses procedures in both TCustomCheckbox and
TRadioButton.

procedure SetChecked(Value: Boolean); override;
procedure GetChecked(Value: Boolean); override;

Yosi Taguri <yo...@writeme.com> wrote in message
news:7peqrc$27...@forums.borland.com...

Raj Sidhu

unread,
Aug 19, 1999, 3:00:00 AM8/19/99
to
Hi,

Why do you want to do that? Anyway here's a simple solution. Have two global
variables.. FChecked and FEnabled (boolean). When you want to stop the user
changing the value of the checkbox but not disable it set the FChecked
variable to the value you want (either checked or unchecked) and then the
FEnabled value to false.

Put this code in the CheckBox1Click procedure:

if not FEnabled then
checkbox1.checked := FChecked;

-- Raj


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Parampreet Sidhu (Programmer Consultant)
CITYPRO International Ltd, 107-112 Leadenhall Street, London, UK
Tel: +44 171 891 2466 Fax: +44 171 891 2467
email: psi...@citypro.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Ing. Víctor M. Ojeda Valiente

unread,
Aug 19, 1999, 3:00:00 AM8/19/99
to
The easiest way, just put Abort in the OnClick event.

Yosi Taguri escribió en mensaje <7peqrc$27...@forums.borland.com>...

Steve Zimmelman

unread,
Aug 19, 1999, 3:00:00 AM8/19/99
to
That won't work. The OnClick fires after the value of checked has changed.

Ing. Víctor M. Ojeda Valiente <voj...@uaa.edu.py> wrote in message
news:7ph25b$4k...@forums.borland.com...

David Baer

unread,
Aug 19, 1999, 3:00:00 AM8/19/99
to
Yosi,

>how can I make it them Readonly without making them Enable:=False

Override the Toggle method of TCheckBox. In Toggle, exit if the
control is in a readonly state, otherwise call inherited.

Regards,
D.B.

Chris Ruml

unread,
Aug 19, 1999, 3:00:00 AM8/19/99
to
Yosi Taguri wrote:

> how can I make it them Readonly without making them Enable:=False
>

> I tried to Add TCustomCheckBox a published Readonly property
> wich checks and sets ClicksDisabled ... but it didn't work...
>
> yosi

How about putting it on a panel and disabling the panel?

Chris.


Yosi Taguri

unread,
Aug 19, 1999, 3:00:00 AM8/19/99
to
I edited the SetChecked of TcustomCheckBox
and made a readonly property ... and it worked..

also the toggle works...

thnks...

procedure TCustomCheckBox.SetChecked(Value: Boolean);
begin
if not FReadOnly then
if Value then State := cbChecked else State := cbUnchecked;
end;

OR


procedure TCustomCheckBox.Toggle;
begin
if FreadOnly then Exit;
case State of
cbUnchecked:
if AllowGrayed then State := cbGrayed else State := cbChecked;
cbChecked: State := cbUnchecked;
cbGrayed: State := cbChecked;
end;
end;

yosi


David Baer <db...@speartechnologies.com> wrote in message
news:37bc215f...@forums.borland.com...
> Yosi,


>
> >how can I make it them Readonly without making them Enable:=False
>

0 new messages