频道栏目
首页 > 程序开发 > 软件开发 > Delphi > 正文
Delphi速选组件
2015-05-26 08:34:03      个评论    来源:fanhongbin的专栏  
收藏   我要投稿
{*******************************************************}
{                                                                             }
{       速选组件                                                       }
{                                                                            }
{       版权所有 (C) 2015.5 hbfan                           }
{                                                                            }
{*******************************************************}

unit FastSelect;


interface

uses
  Classes, Controls, StdCtrls, CheckLst;

type
  TFASTSELECT = class(TComponent)
  private
    FSelectAllRaiseObject: TwinControl;
    FSelectClearRaiseObject: TwinControl;
    FSelectionSource: TwinControl;
    FSelectReversedRaiseObject: TwinControl;
    procedure SetSelectAllRaiseObject(const Value: TwinControl);
    procedure SetSelectClearRaiseObject(const Value: TwinControl);
    procedure SetSelectReversedRaiseObject(const Value: TwinControl);

    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
     // 全选
     procedure OnSelectedAll(sender: Tobject);
     // 清空
     procedure OnSelectedClear(sender: Tobject);
  published
    { Published declarations }
    // 全选组件
    property SelectAllRaiseObject: TwinControl read FSelectAllRaiseObject write
        SetSelectAllRaiseObject;
    // 清空组件
    property SelectClearRaiseObject: TwinControl read FSelectClearRaiseObject write
        SetSelectClearRaiseObject;
    // 反选组件
    property SelectReversedRaiseObject: TwinControl read FSelectReversedRaiseObject
        write SetSelectReversedRaiseObject;
    // 数据源组件
    property SelectionSource: TwinControl read FSelectionSource write
        FSelectionSource;

  end;

procedure Register;

implementation
{$R *.dcr}

procedure Register;
begin
  RegisterComponents('hbfan', [TFastSelect]);
end;

procedure TFastSelect.OnSelectedAll(sender: Tobject);
var
   i: integer;
   FSourceListBox: TcheckListBox;
begin
  if FSelectionSource is TcheckListBox then
  begin
    FSourceListBox := (FselectionSource as TcheckListBox);
    for i := 0 to FSourceListBox.Count - 1 do
      FsourceListBox.Checked[i] := true;
  end;
end;

procedure TFastSelect.OnSelectedClear(sender: Tobject);
var
   i: integer;
   FSourceListBox: TcheckListBox;
begin
  if FSelectionSource is TcheckListBox then
  begin
    FSourceListBox := (FselectionSource as TcheckListBox);
    for i := 0 to FSourceListBox.Count - 1 do
      FsourceListBox.Checked[i] := false;
  end;
end;

procedure TFastSelect.SetSelectAllRaiseObject(const Value: TwinControl);
begin
  FSelectAllRaiseObject := Value;
  if Value is Tbutton then
  begin
    (value as Tbutton).Caption := '全选';
    (value as Tbutton).OnClick := OnSelectedAll;
  end;
end;

procedure TFastSelect.SetSelectClearRaiseObject(const Value: TwinControl);
begin
  FSelectClearRaiseObject := Value;                                                                                                                       
  if Value is Tbutton then
  begin
    (value as Tbutton).Caption := '清空';
    (value as Tbutton).OnClick := OnSelectedClear;
  end;
end;

procedure TFastSelect.SetSelectReversedRaiseObject(
  const Value: TwinControl);
begin
  FSelectReversedRaiseObject := Value;
  if Value is Tbutton then
  begin
    (value as Tbutton).Caption := '反选';
    (value as Tbutton).OnClick := OnSelectedReversed;
  end;
end;

end.


点击复制链接 与好友分享!回本站首页
相关TAG标签 组件
上一篇:Delphi 提取TXT中的Email 数据
下一篇:Delphi中Chrome Chromium、Cef3学习笔记
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站