程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi速選組件

Delphi速選組件

編輯:Delphi

Delphi速選組件


{*******************************************************}
{                                                                             }
{       速選組件                                                       }
{                                                                            }
{       版權所有 (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.


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved