procedure TForm1.CheckListBox1ClickCheck(Sender: TObject); var index : integer; i:integer; sender1:Tobject; begin CheckListBox1Click(Sender1); index:=CheckListBox1.ItemIndex; if CheckListBox1.Checked[index] then begin for i:=0 to CheckListBox2.Count-1 do CheckListBox2.Checked[i]:=true; CheckListBox2.Enabled:=true; end else begin for i:=0 to CheckListBox2.Count-1 do CheckListBox2.Checked[i]:=false; CheckListBox2.Enabled:=false; end; CheckListBox2Click(Sender1); end;
例: 在Button2的onClick事件中触发Button1的onClick事件! procedure TForm1.Button1Click(Sender: TObject); begin showmessage('按钮一'); end;procedure TForm1.Button2Click(Sender: TObject); begin showmessage('按钮二'); Button1.OnClick(nil); end;
var index : integer;
i:integer;
sender1:Tobject;
begin
CheckListBox1Click(Sender1);
index:=CheckListBox1.ItemIndex;
if CheckListBox1.Checked[index] then
begin
for i:=0 to CheckListBox2.Count-1 do
CheckListBox2.Checked[i]:=true;
CheckListBox2.Enabled:=true;
end
else
begin
for i:=0 to CheckListBox2.Count-1 do
CheckListBox2.Checked[i]:=false;
CheckListBox2.Enabled:=false;
end;
CheckListBox2Click(Sender1);
end;
在Button2的onClick事件中触发Button1的onClick事件!
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage('按钮一');
end;procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage('按钮二');
Button1.OnClick(nil);
end;