链接:https://pan.baidu.com/s/1zSnOXsY5fwGj-g_S71QgyQ
提取码:4ljr
procedure Tmainform.checklistboxclick(Sender: TObject); begin if (sender as TUniCheckBox).Checked then begin ShowMessage((sender as TUniCheckBox).Caption); end; //You can use check or tag or the other properties of TunicheckBox end; procedure TMainForm.UniBitBtn1Click(Sender: TObject); var c : TuniCheckBox; p : TuniPanel; I: Integer; begin if UniScrollBox1.ComponentCount=0 then begin //只创建 一次 for I := 0 to 40 do begin c:= TUniCheckBox.Create(UniScrollBox1); c.Parent := UniScrollBox1; c.Caption := IntToStr(i)+'. CheckItems'; c.OnClick :=checklistboxclick; c.Tag := i;// You can use tag like items index that like checkboxlist c.Align := altop; end; p := TUniPanel.Create(UniScrollBox1); ///Q:why are there uniPanel ? 为什么用panel的Parent设为 UniScrollBox1? p.Parent := UniScrollBox1; p.Height :=0; p.Align := alTop; //A: Because the last check items of the loop is ride on the the last items. //Panel is hidden that. end; end; procedure TMainForm.UniBitBtn2Click(Sender: TObject); var I: Integer; begin UniMemo1.Clear; for I := 0 to UniScrollBox1.ComponentCount-1 do if UniScrollBox1.Components[i].ClassType= TUniCheckBox then if TUniCheckBox(UniScrollBox1.Components[i]).Checked then begin UniMemo1.Lines.Add('======================================='); UniMemo1.Lines.Add('Cap :'+ TUniCheckBox(UniScrollBox1.Components[i]).Caption); UniMemo1.Lines.Add('Item Index :'+ IntToStr(TUniCheckBox(UniScrollBox1.Components[i]).tag)); UniMemo1.Lines.Add('======================================='); end; end;