jeudi 5 février 2015

Delphi How to have an exclusive relationship between TDBCheckBoxes

I have a group of db check boxes with a "none of the above" box at the end. What I want to do is if the "none of the above" is clicked, it clears the rest. And if it is already selected, and any other one is clicked, then clear the "none of the above" box.



procedure TformLOC30v15.chkC0900AClick(Sender: TObject);

begin
if chkC0900Z.Checked = True then
begin

if not(tblMNLOC30.State in [dsEdit, dsInsert]) then
tblMNLOC30.Edit;
tblmnloc30.FieldByName('C0900Z').AsString := '';
tblmnloc30.Post;
tblMNLOC30.Edit;
end;
end;

procedure TformLOC30v15.chkC0900ZClick(Sender: TObject);
begin
if chkC0900Z.Checked = True then
begin
if not(tblMNLOC30.State in [dsEdit, dsInsert]) then
tblMNLOC30.Edit;
tblmnloc30.FieldByName('C0900A').AsString := '';
tblmnloc30.FieldByName('C0900B').AsString := '';
tblmnloc30.FieldByName('C0900C').AsString := '';
tblmnloc30.FieldByName('C0900D').AsString := '';
tblmnloc30.FieldByName('c0900Z').AsString := 'True';
tblmnloc30.Post;
tblMNLOC30.Edit;
end;
end;


This works for the most part, but when the "none of the above" is selected, and any other box is clicked, the box is cleared, but the box that was clicked will not be selected unless clicking it again. Does anybody know why this is happening? Thank you.





Aucun commentaire:

Enregistrer un commentaire