[DUG] Enable CheckBox
John Bird
johnkbird at paradise.net.nz
Tue Apr 27 12:00:19 NZST 2010
A couple of thoughts on this:
1 - If you want to test its empty it may be more general to go
DBCheckBox4.Enabled := not (trim(DBEdit2.Text) = '') ;
I think as it is it should be OK in this case if the underlying data for DBEdit2 is null, but you may want to check that as well, as a null value can stuff up tests like this sometimes.
2 - A non-initialised DBCheckBox4 can behave a little oddly - it may show as looking disabled simply because the value of DBCheckBox4.checked is seen as neither true nor false. This can happen in D5, not sure about later versions. You may need to initialise it specifically, and check the AllowGrayed property as well.
John Bird
JBCL
Contact:
johnkbird at paradise.net.nz
jbclnz at xtra.co.nz
027 4844528
http://jbclnz.googlepages.com
http://www.jbcl.co.nz
----- Original Message -----
From: David O'Brien
To: NZ Borland Developers Group - Delphi List
Sent: Tuesday, April 27, 2010 10:52 AM
Subject: Re: [DUG] Enable CheckBox
Why the four quotes in the false and a space in the true?
I would use something like:
DBCheckBox4.Enabled := not (DBEdit2.Text = '') ;
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On Behalf Of Bob Pawley
Sent: Tuesday, 27 April 2010 10:39 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Enable CheckBox
Hi
I am attempting to enable a checkbox only when a DBEdit has a value. (Disabled when no string in DBEdit.)
Following is my code which disables the CheckBox after a delete from the DBEdit.
But it is not enabled when I add a string to the DBEdit.
------
procedure TForm4.DBEdit2Change(Sender: TObject);
begin
if
DBEdit2.Text = ' '
then
DBCheckBox4.Enabled := True
Else if DBEdit2.Text = ''''
then
DBCheckBox4.Enabled := False ;
end;
Thanks for any help.
Bob
------------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject: unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20100427/39eb2439/attachment-0001.html
More information about the Delphi
mailing list