Change CheckBox state without calling OnClick Event

后端 未结 8 1692
时光取名叫无心
时光取名叫无心 2021-01-04 06:35

I\'m wondering so when I change state of CheckBox

CheckBox->Checked=false;

It calls CheckBoxOnClick Event , how to avoid it ?

8条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-04 07:11

    Some other and much easier solution is not avoiding the the OnClick event but modifying the event handler not to respond unless the DataSet.State is in either dsEdit or dsInsert as initiated by a user triggered TDBCheckBox click e.g.:

    procedure TForm1.chkSelectClick(Sender: TObject);
    begin
      if chkSelect.Checked = True then
        if DataSource1.DataSet.State in [dsEdit,dsInsert] then
          begin
            { your event handler }
          end;
    end;
    

提交回复
热议问题