⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umycontrol.pas

📁 下拉控件例子代码 下拉控件例子代码 下拉控件例子代码
💻 PAS
字号:
unit uMyControl;

interface
uses
  SysUtils, StdCtrls, Controls, Classes, Variants, DBCtrlsEh, ToolCtrlsEh;
type
  TGISCombo = class(TCustomDBComboBoxEh)
  private
    FAccept: Boolean;
    FListVisible: Boolean;
    ItemIndex: Integer;
    FItemIndex: Integer;
    FAutoValue: Boolean;
    FCtl3D: Boolean;
    procedure SetItemIndex(const Value: Integer);
    procedure SetCtl3D(const Value: Boolean);
  protected
    procedure InternalSetItemIndex(const Value: Integer); override;
    procedure CloseUp(Accept: Boolean); override;
  public
    property Color;
    property Hint;
    property ShowHint;
    property OnChange;
    property OnClick;
    property OnKeyUp;
    property AutoValue: Boolean read FAutoValue write FAutoValue default True;
    property Ctl3D: Boolean read FCtl3D write SetCtl3D default True;
    function GetPopupListboxEx: TWinControl;
    constructor Create(AOwner: TComponent); override;
  end;
implementation

{ TMyCombo }

procedure TGISCombo.CloseUp(Accept: Boolean);
begin
  FAccept := Accept;
  inherited;

end;

constructor TGISCombo.Create(AOwner: TComponent);
begin
  inherited;
  FAutoValue := True;
  FCtl3D := True;
  FAccept := False;
end;

function TGISCombo.GetPopupListboxEx: TWinControl;
begin
  Result := GetPopupListbox;
end;

procedure TGISCombo.InternalSetItemIndex(const Value: Integer);
begin
  if FItemIndex <> Value then
  begin
    GetItemsList;
    if (Value >= 0) and (Value < FItemsCount) then
    begin
      FItemIndex := Value;
      if FKeyBased then
        FVarValue := KeyItems.Strings[FItemIndex];
    end else
    begin
      FItemIndex := -1;
      FVarValue := Null;
    end;
    UpdateImageIndex;
    if FListVisible then
      TPopupListboxEh(PopupListbox).ItemIndex := FItemIndex;
    if (FItemIndex >= 0) and (AutoValue or FAccept) then
      //inherited InternalSetText(Items.Strings[FItemIndex])
      EditText := Items.Strings[FItemIndex]
    //else inherited InternalSetText('');
  end;
end;

procedure TGISCombo.SetCtl3D(const Value: Boolean);
begin
  FCtl3D := Value;
  TPopupListboxEh(GetPopupListbox).Ctl3D := FCtl3D;
end;

procedure TGISCombo.SetItemIndex(const Value: Integer);
begin
  FItemIndex := Value;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -