吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3673|回复: 14
收起左侧

[其他转载] Delphi动态复选框源码:

[复制链接]
冥界3大法王 发表于 2018-11-28 17:37


Snap58.png
[Delphi] 纯文本查看 复制代码
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, CheckLst;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Panel1: TPanel;
    CheckListBox1: TCheckListBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject); //全选
var
  i: Integer;
begin
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    if (Panel1.Controls[i].ClassType = TCheckBox) then
    begin
      TCheckBox(Panel1.Controls[i]).Checked := True;
    end;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject); //取消全部选择
var
  i: Integer;
begin
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    if (Panel1.Controls[i].ClassType = TCheckBox) then
    begin
      TCheckBox(Panel1.Controls[i]).Checked := False;
    end;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject); //反选
var
  i: Integer;
begin
  for i := 0 to Panel1.ControlCount - 1 do
  begin
    if (Panel1.Controls[i].ClassType = TCheckBox) then
    begin
      if TCheckBox(Panel1.Controls[i]).Checked then
        TCheckBox(Panel1.Controls[i]).Checked := false
      else
        TCheckBox(Panel1.Controls[i]).Checked := True;
    end;
  end;
end;

procedure TForm1.Button4Click(Sender: TObject); //全选
var
  i: integer;
begin
  for i := 0 to CheckListBox1.Items.Count - 1 do
  begin
    CheckListBox1.Checked[i] := True; //反选设置为False
    //写入到文件
  end;
end;




procedure TForm1.Button5Click(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to CheckListBox1.Items.Count - 1 do
  begin
    if CheckListBox1.Checked[i] = True then
      ShowMessage(CheckListBox1.Items[i]);
    //写入到文件
  end;
end;

procedure TForm1.Button6Click(Sender: TObject);       //清空,便于加入新的一组
begin
  CheckListBox1.Items.Clear;
end;

end.

免费评分

参与人数 2吾爱币 +4 热心值 +2 收起 理由
苏紫方璇 + 3 + 1 用心讨论,共获提升!
lyrong + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Do_zh 发表于 2018-11-28 18:01
感谢分享,楼主辛苦了。。
sxtylhg 发表于 2018-11-28 23:41
写的不错么,一看就是下了一番功夫的,支持楼主!楼主 Delphi Xe 10.3 RIO 出来了,晓得不
/bq 发表于 2018-11-29 08:54
头像被屏蔽
pjchangew 发表于 2018-11-29 23:10
提示: 作者被禁止或删除 内容自动屏蔽
homejun 发表于 2018-11-30 12:22
恭喜调试成功,delphi做为VB杀手,win平台上个人RAD开发还是最好的选择!
jyopen 发表于 2018-12-1 14:14
感谢分享,Delphi挺实用的
hying95 发表于 2020-2-7 20:16
Delphi挺好用
nshark 发表于 2020-2-8 01:38
看着就熟悉和亲切
qwert813 发表于 2020-2-16 08:34
很高兴还有人用Delphi,这个源码应该是研究性的,不是实用性的。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-26 00:59

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表