有个事件里面写了代码,在运行时事件执行后我想停止他不知道怎么写代码?
比如:
procedure Tfr_priceNew.cmbzxrqSelect(Sender: TObject);
begin
  if cmbzxrq.ItemIndex=0 then begin
    tzs.OnTimer
    meddate.Text:='____-__-__';
    medtime.Text:='__:__:__';
  end else begin
    meddate.Text:=dbsysdate;
    tzs.OnTimer:=timeontime;
  end;
end;procedure Tfr_pricenew.timeontime(sender:tobject);
begin
  medtime.Text:= dbsystime;
end;
在这里cmbzxrq.ItemIndex<>0时执行timeontime事件或在选择cmbzxrq.ItemIndex=0时
timeontime事件继续发生。
不知道有没有办法不让他发生呢?

解决方案 »

  1.   

    不知道什么意思。
    cmbzxrq.ItemIndex <> 0时,你没让它执行timeontime啊,只是指定了timer的OnTimer事件而已。
    不让它发生么就不要写相关的执行代码好了。
      

  2.   

    tzs.Enabled := True; 执行
    tzs.Enabled := False; 不执行
      

  3.   

    不知道有没有方法做到已经赋给的事件(tzs.OnTimer:=timeontime;)清除呢?
      

  4.   

    tzs.OnTimer := nil;  ( 赋于空指针 )
    tzs.OnTimer:=timeontime;