cxdblookupcombobox.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 654 行 · 第 1/2 页
PAS
654 行
{********************************************************************}
{ }
{ Developer Express Visual Component Library }
{ ExpressEditors }
{ }
{ Copyright (c) 1998-2008 Developer Express Inc. }
{ ALL RIGHTS RESERVED }
{ }
{ The entire contents of this file is protected by U.S. and }
{ International Copyright Laws. Unauthorized reproduction, }
{ reverse-engineering, and distribution of all or any portion of }
{ the code contained in this file is strictly prohibited and may }
{ result in severe civil and criminal penalties and will be }
{ prosecuted to the maximum extent possible under the law. }
{ }
{ RESTRICTIONS }
{ }
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
{ (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE }
{ SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS }
{ LICENSED TO DISTRIBUTE THE EXPRESSEDITORS AND ALL }
{ ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
{ }
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
{ }
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
{ ADDITIONAL RESTRICTIONS. }
{ }
{********************************************************************}
unit cxDBLookupComboBox;
{$I cxVer.inc}
interface
uses
{$IFDEF DELPHI6}
Variants,
{$ENDIF}
Windows, Messages, SysUtils, Classes, Controls, Graphics, DB, DBCtrls,
cxClasses, cxContainer, cxCustomData, cxDataStorage, cxDB, cxDBData,
cxLookAndFeels, cxEdit, cxDBEdit, cxEditConsts, cxDropDownEdit,
cxLookupEdit, cxDBLookupEdit, cxLookupGrid, cxLookupDBGrid,
cxFilterControlUtils;
type
{ TcxLookupComboBoxProperties }
TcxLookupComboBoxProperties = class(TcxCustomDBLookupEditProperties)
private
FGrid: TcxCustomLookupDBGrid;
function GetGrid: TcxCustomLookupDBGrid;
function GetGridMode: Boolean;
function GetListColumns: TcxLookupDBGridColumns;
function GetListOptions: TcxLookupDBGridOptions;
function GetListSource: TDataSource;
function GetOnSortingChanged: TNotifyEvent;
procedure SetGridMode(Value: Boolean);
procedure SetListColumns(Value: TcxLookupDBGridColumns);
procedure SetListOptions(Value: TcxLookupDBGridOptions);
procedure SetListSource(Value: TDataSource);
procedure SetOnSortingChanged(Value: TNotifyEvent);
protected
function GetLookupGridClass: TcxCustomLookupDBGridClass; virtual;
procedure ListOptionsChanged(Sender: TObject); virtual;
// LookupGrid methods
function GetLookupGridColumnCount: Integer; override;
function GetLookupGridControl: TWinControl; override;
function GetLookupGridDataController: TcxCustomDataController; override;
function GetLookupGridVisualAreaPreferredWidth: Integer; override;
function GetLookupGridNearestPopupHeight(AHeight: Integer): Integer; override;
function GetLookupGridPopupHeight(ADropDownRowCount: Integer): Integer; override;
function IsLookupGridMouseOverList(const P: TPoint): Boolean; override;
procedure LookupGridInitEvents(AOnClick, AOnFocusedRowChanged: TNotifyEvent;
AOnCloseUp: cxLookupEdit.TcxLookupGridCloseUpEvent); override;
procedure LookupGridInitLookAndFeel(ALookAndFeel: TcxLookAndFeel; AColor: TColor; AFont: TFont); override;
procedure LookupGridLockMouseMove; override;
procedure LookupGridMakeFocusedRowVisible; override;
procedure LookupGridUnlockMouseMove; override;
// DBLookupGrid methods
procedure DBLookupGridBeginUpdate; override;
procedure DBLookupGridCheckColumnByFieldName(const AFieldName: string); override;
procedure DBLookupGridCreateColumnsByFieldNames(const AFieldNames: string); override;
procedure DBLookupGridEndUpdate; override;
function GetDBLookupGridColumnField(AIndex: Integer): TField; override;
function GetDBLookupGridColumnFieldName(AIndex: Integer): string; override;
function GetDBLookupGridColumnIndexByFieldName(const AFieldName: string): Integer; override;
function GetDBLookupGridDataController: TcxDBDataController; override;
public
constructor Create(AOwner: TPersistent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
class function GetContainerClass: TcxContainerClass; override;
property Grid: TcxCustomLookupDBGrid read GetGrid;
published
property Alignment;
property AutoSelect;
property AssignedValues;
property ButtonGlyph;
property CaseSensitiveSearch;
property CharCase;
property ClearKey;
property DropDownAutoSize;
property DropDownHeight;
property DropDownListStyle;
property DropDownRows;
property DropDownSizeable;
property DropDownWidth;
property GridMode: Boolean read GetGridMode write SetGridMode default False;
property HideSelection;
property ImeMode;
property ImeName;
property ImmediateDropDown;
property ImmediatePost;
property IncrementalFiltering;
property KeyFieldNames;
property ListColumns: TcxLookupDBGridColumns read GetListColumns write SetListColumns;
property ListFieldNames;
property ListFieldIndex;
property ListOptions: TcxLookupDBGridOptions read GetListOptions write SetListOptions;
property ListSource: TDataSource read GetListSource write SetListSource;
property MaxLength;
property OEMConvert;
property PopupAlignment;
property PostPopupValueOnTab;
property ReadOnly;
property Revertable;
property UseLeftAlignmentOnEditing;
property ValidateOnEnter;
property OnChange;
property OnCloseUp;
property OnEditValueChanged;
property OnInitPopup;
property OnNewLookupDisplayText;
property OnPopup;
property OnSortingChanged: TNotifyEvent read GetOnSortingChanged write SetOnSortingChanged;
property OnValidate;
end;
{ TcxCustomLookupComboBox }
TcxCustomLookupComboBox = class(TcxCustomDBLookupEdit)
private
function GetProperties: TcxLookupComboBoxProperties;
function GetActiveProperties: TcxLookupComboBoxProperties;
procedure SetProperties(Value: TcxLookupComboBoxProperties);
public
class function GetPropertiesClass: TcxCustomEditPropertiesClass; override;
property ActiveProperties: TcxLookupComboBoxProperties
read GetActiveProperties;
property EditValue;
property Properties: TcxLookupComboBoxProperties read GetProperties
write SetProperties;
property Text;
end;
{ TcxLookupComboBox }
TcxLookupComboBox = class(TcxCustomLookupComboBox)
published
property Anchors;
property AutoSize;
property BeepOnEnter;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property ImeMode;
property ImeName;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property Properties;
property EditValue;
property ShowHint;
property Style;
property StyleDisabled;
property StyleFocused;
property StyleHot;
property TabOrder;
property TabStop;
property Visible;
property OnClick;
{$IFDEF DELPHI5}
property OnContextPopup;
{$ENDIF}
property OnDblClick;
property OnEditing;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
{ TcxDBLookupComboBox }
TcxDBLookupComboBox = class(TcxCustomLookupComboBox)
private
function GetDataBinding: TcxDBTextEditDataBinding;
procedure SetDataBinding(Value: TcxDBTextEditDataBinding);
procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
protected
class function GetDataBindingClass: TcxEditDataBindingClass; override;
published
property Anchors;
property AutoSize;
property BeepOnEnter;
property Constraints;
property DragCursor;
property DragKind;
property DataBinding: TcxDBTextEditDataBinding read GetDataBinding
write SetDataBinding;
property DragMode;
property Enabled;
property ImeMode;
property ImeName;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property Properties;
property ShowHint;
property Style;
property StyleDisabled;
property StyleFocused;
property StyleHot;
property TabOrder;
property TabStop;
property Visible;
property OnClick;
{$IFDEF DELPHI5}
property OnContextPopup;
{$ENDIF}
property OnDblClick;
property OnEditing;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
{ TcxFilterLookupComboBoxHelper }
TcxFilterLookupComboBoxHelper = class(TcxFilterComboBoxHelper)
protected
class function IsIDefaultValuesProviderNeeded(
AEditProperties: TcxCustomEditProperties): Boolean; override;
public
class function GetFilterEditClass: TcxCustomEditClass; override;
class procedure GetFilterValue(AEdit: TcxCustomEdit; AEditProperties: TcxCustomEditProperties;
var V: Variant; var S: TCaption); override;
class function GetSupportedFilterOperators(
AProperties: TcxCustomEditProperties;
AValueTypeClass: TcxValueTypeClass;
AExtendedSet: Boolean = False): TcxFilterControlOperators; override;
class procedure InitializeProperties(AProperties,
AEditProperties: TcxCustomEditProperties; AHasButtons: Boolean); override;
class function IsValueValid(AValueTypeClass: TcxValueTypeClass;
var Value: Variant): Boolean; override;
end;
implementation
uses
{$IFDEF DELPHI6}
VDBConsts,
{$ENDIF}
DBConsts, cxTextEdit;
type
TControlAccess = class(TControl);
{ TcxLookupComboBoxProperties }
constructor TcxLookupComboBoxProperties.Create(AOwner: TPersistent);
begin
inherited Create(AOwner);
FGrid := GetLookupGridClass.Create(nil);
FGrid.IsPopupControl := True;
FGrid.Options.OnChanged := ListOptionsChanged;
InitializeDataController;
end;
destructor TcxLookupComboBoxProperties.Destroy;
begin
DeinitializeDataController;
FGrid.Free;
FGrid := nil;
inherited Destroy;
end;
procedure TcxLookupComboBoxProperties.Assign(Source: TPersistent);
begin
if Source is TcxLookupComboBoxProperties then
begin
BeginUpdate;
try
GridMode := TcxLookupComboBoxProperties(Source).GridMode;
ListOptions := TcxLookupComboBoxProperties(Source).ListOptions;
if not IsDefinedByLookup then
begin
ListSource := TcxLookupComboBoxProperties(Source).ListSource;
ListColumns := TcxLookupComboBoxProperties(Source).ListColumns;
end;
OnSortingChanged := TcxLookupComboBoxProperties(Source).OnSortingChanged;
inherited Assign(Source);
if IsDefinedByLookup then
ListColumns := TcxLookupComboBoxProperties(Source).ListColumns;
finally
EndUpdate;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?