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:
[email protected]
[email protected]
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: [email protected] [mailto:[email protected]] 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: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with Subject:
unsubscribe_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with Subject:
unsubscribe