Delphi速选组件

页面导航:首页 > 软件编程 > Delphi > Delphi速选组件

Delphi速选组件

来源: 作者: 时间:2016-01-21 09:33 【

{*******************************************************}{
{*******************************************************}
{                                                                             }
{       速选                                                       }
{                                                                            }
{       版权所有 (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.


Tags:

文章评论

最 近 更 新
热 点 排 行
Js与CSS工具
代码转换工具

<