📄 dbgrideh.pas
字号:
end;
{ TColumnEh }
TColCellParamsEh = class
protected
FAlignment: TAlignment;
FBackground: TColor;
FCheckboxState: TCheckBoxState;
FCol: Longint;
FFont: TFont;
FImageIndex: Integer;
FReadOnly: Boolean;
FRow: Longint;
FState: TGridDrawState;
FText: String;
public
property Alignment: TAlignment read FAlignment write FAlignment;
property Background: TColor read FBackground write FBackground;
property CheckboxState: TCheckBoxState read FCheckboxState write FCheckboxState;
property Col: Longint read FCol;
property Font: TFont read FFont;
property ImageIndex: Integer read FImageIndex write FImageIndex;
property ReadOnly: Boolean read FReadOnly write FReadOnly;
property Row: Longint read FRow;
property State: TGridDrawState read FState;
property Text: String read FText write FText;
end;
TGetColCellParamsEventEh = procedure (Sender: TObject; EditMode: Boolean;
Params: TColCellParamsEh) of object;
TColCellUpdateDataEventEh = procedure(Sender: TObject; var Text: String;
var Value: Variant; var UseText: Boolean; var Handled: Boolean) of object;
TColumnEh = class(TCollectionItem)
private
FAlignment: TAlignment;
FAssignedValues: TColumnEhValues;
FButtonStyle: TColumnButtonStyleEh;
FCheckboxes: Boolean;
FColor: TColor;
FDblClickNextVal: Boolean;
FDropDownRows: Cardinal;
FDropDownShowTitles: Boolean;
FDropDownSizing: Boolean;
FDropDownSpecRow: TSpecRowEh;
FEditButtons: TEditButtonsEh;
FField: TField;
FFieldName: string;
FFont: TFont;
FFooter: TColumnFooterEh;
FFooters: TColumnFootersEh;
FImageList: TCustomImageList;
FImeMode: TImeMode;
FImeName: TImeName;
FIncrement: Extended;
FKeyList: TStrings;
FMaxWidth: Integer;
FMinWidth: Integer;
FNotInKeyListIndex: Integer;
FNotInWidthRange:Boolean;
FOnButtonClick: TButtonClickEventEh;
FOnButtonDown: TButtonDownEventEh;
FOnGetCellParams: TGetColCellParamsEventEh;
FOnNotInList: TNotInListEventEh;
FPickList: TStrings;
FPopupMenu: TPopupMenu;
FReadonly: Boolean;
FStored: Boolean;
FTag: Longint;
FTitle: TColumnTitleEh;
FToolTips: Boolean;
FUpdateData: TColCellUpdateDataEventEh;
FVisible: Boolean;
FWidth: Integer;
function DefaultCheckboxes: Boolean;
function GetAlignment: TAlignment;
function GetAlwaysShowEditButton: Boolean;
function GetAutoDropDown: Boolean;
function GetCheckboxes: Boolean;
function GetCheckboxState: TCheckBoxState;
function GetColor: TColor;
function GetDblClickNextVal: Boolean;
function GetDropDownShowTitles: Boolean;
function GetDropDownSizing: Boolean;
function GetEndEllipsis: Boolean;
function GetField: TField;
function GetFont: TFont;
function GetImeMode: TImeMode;
function GetImeName: TImeName;
function GetKeykList: TStrings;
function GetPickList: TStrings;
function GetReadOnly: Boolean;
function GetToolTips:Boolean;
function GetWidth: Integer;
function IsAlignmentStored: Boolean;
function IsAlwaysShowEditButtonStored: Boolean;
function IsAutoDropDownStored: Boolean;
function IsCheckboxesStored: Boolean;
function IsColorStored: Boolean;
function IsDblClickNextValStored: Boolean;
function IsDropDownShowTitlesStored: Boolean;
function IsDropDownSizingStored: Boolean;
function IsEndEllipsisStored: Boolean;
function IsFontStored: Boolean;
function IsImeModeStored: Boolean;
function IsImeNameStored: Boolean;
function IsIncrementStored: Boolean;
function IsReadOnlyStored: Boolean;
function IsToolTipsStored: Boolean;
function IsWidthStored: Boolean;
procedure EditButtonChanged(Sender: TObject);
procedure FontChanged(Sender: TObject);
procedure SetAlignment(Value: TAlignment); virtual;
procedure SetButtonStyle(Value: TColumnButtonStyleEh);
procedure SetCheckboxes(const Value: Boolean);
procedure SetCheckboxState(const Value: TCheckBoxState);
procedure SetColor(Value: TColor);
procedure SetDblClickNextVal(const Value: Boolean);
procedure SetDropDownShowTitles(const Value: Boolean);
procedure SetDropDownSizing(const Value: Boolean);
procedure SetDropDownSpecRow(const Value: TSpecRowEh);
procedure SetEditButtons(const Value: TEditButtonsEh);
procedure SetField(Value: TField); virtual;
procedure SetFieldName(const Value: String);
procedure SetFont(Value: TFont);
procedure SetFooter(const Value: TColumnFooterEh);
procedure SetFooters(const Value: TColumnFootersEh);
procedure SetImageList(const Value: TCustomImageList);
procedure SetImeMode(Value: TImeMode); virtual;
procedure SetImeName(Value: TImeName); virtual;
procedure SetKeykList(const Value: TStrings);
procedure SetMaxWidth(const Value: Integer);
procedure SetMinWidth(const Value: Integer);
procedure SetNotInKeyListIndex(const Value: Integer);
procedure SetOnGetCellParams(const Value: TGetColCellParamsEventEh);
procedure SetPickList(Value: TStrings);
procedure SetPopupMenu(Value: TPopupMenu);
procedure SetReadOnly(Value: Boolean); virtual;
procedure SetTitle(Value: TColumnTitleEh);
procedure SetToolTips(const Value: Boolean);
procedure SetVisible(const Value: Boolean);
procedure SetWidth(Value: Integer); virtual;
protected
FAlwaysShowEditButton: Boolean;
FAutoDropDown: Boolean;
FAutoFitColWidth:Boolean;
FDropDownWidth: Integer;
FEndEllipsis: Boolean;
FInitWidth:Integer;
FLookupDisplayFields:String;
FWordWrap:Boolean;
function AllowableWidth(TryWidth:Integer):Integer;
function CreateEditButtons: TEditButtonsEh; virtual;
function CreateFooter: TColumnFooterEh; virtual;
function CreateFooters: TColumnFootersEh; virtual;
function CreateTitle: TColumnTitleEh; virtual;
function DefaultAlwaysShowEditButton: Boolean;
function DefaultAutoDropDown: Boolean;
function DefaultDblClickNextVal: Boolean;
function DefaultDropDownShowTitles: Boolean;
function DefaultDropDownSizing: Boolean;
function DefaultEndEllipsis: Boolean;
function DefaultLookupDisplayFields: String;
function DefaultToolTips: Boolean;
function DefaultWordWrap: Boolean;
function GetAutoFitColWidth: Boolean;
function GetDisplayName: string; override;
function GetGrid: TCustomDBGridEh;
function GetLookupDisplayFields: String;
function GetWordWrap: Boolean;
function IsLookupDisplayFieldsStored: Boolean;
function IsWordWrapStored: Boolean;
procedure EnsureSumValue;
procedure RefreshDefaultFont;
procedure SetAlwaysShowEditButton(Value: Boolean);
procedure SetAutoDropDown(Value: Boolean);
procedure SetAutoFitColWidth(Value: Boolean); virtual;
procedure SetDropDownWidth(Value: Integer);
procedure SetEndEllipsis(const Value: Boolean);
procedure SetIndex(Value: Integer); override;
procedure SetLookupDisplayFields(Value:String); virtual;
procedure SetNextFieldValue(Increment: Extended);
procedure SetWordWrap(Value: Boolean); virtual;
procedure SpecRowChanged(Sender: TObject); virtual;
procedure UpdateDataValues(Text: String; Value: Variant; UseText: Boolean);
property IsStored: Boolean read FStored write FStored default True;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
function CanModify(TryEdit:Boolean):Boolean;
function DefaultAlignment: TAlignment;
function DefaultColor: TColor;
function DefaultFont: TFont;
function DefaultImeMode: TImeMode;
function DefaultImeName: TImeName;
function DefaultReadOnly: Boolean;
function DefaultWidth: Integer;
function DisplayText: String;
function EditButtonsWidth: Integer;
function GetColumnType: TColumnEhType;
function GetImageIndex: Integer;
function UsedFooter(Index: Integer): TColumnFooterEh;
procedure Assign(Source: TPersistent); override;
procedure DropDown;
procedure FillColCellParams(ColCellParamsEh: TColCellParamsEh);
procedure GetColCellParams(EditMode: Boolean; ColCellParamsEh: TColCellParamsEh); virtual;
procedure RestoreDefaults; virtual;
property AssignedValues: TColumnEhValues read FAssignedValues;
property CheckboxState: TCheckBoxState read GetCheckboxState write SetCheckboxState;
property Field: TField read GetField write SetField;
property Grid: TCustomDBGridEh read GetGrid;
published
property Alignment: TAlignment read GetAlignment write SetAlignment stored IsAlignmentStored;
property AlwaysShowEditButton: Boolean read GetAlwaysShowEditButton write SetAlwaysShowEditButton stored IsAlwaysShowEditButtonStored;
property AutoDropDown: Boolean read GetAutoDropDown write SetAutoDropDown stored IsAutoDropDownStored;
property AutoFitColWidth: Boolean read GetAutoFitColWidth write SetAutoFitColWidth default True;
property ButtonStyle: TColumnButtonStyleEh read FButtonStyle write SetButtonStyle default cbsAuto;
property Checkboxes: Boolean read GetCheckboxes write SetCheckboxes stored IsCheckboxesStored;
property Color: TColor read GetColor write SetColor stored IsColorStored;
property DblClickNextVal: Boolean read GetDblClickNextVal write SetDblClickNextVal stored IsDblClickNextValStored;
property DropDownRows: Cardinal read FDropDownRows write FDropDownRows default 7;
property DropDownShowTitles: Boolean read GetDropDownShowTitles write SetDropDownShowTitles stored IsDropDownShowTitlesStored;
property DropDownSizing: Boolean read GetDropDownSizing write SetDropDownSizing stored IsDropDownSizingStored;
property DropDownSpecRow: TSpecRowEh read FDropDownSpecRow write SetDropDownSpecRow;
property DropDownWidth: Integer read FDropDownWidth write SetDropDownWidth default 0;
property EditButtons: TEditButtonsEh read FEditButtons write SetEditButtons;
property EndEllipsis: Boolean read GetEndEllipsis write SetEndEllipsis stored IsEndEllipsisStored;
property FieldName: String read FFieldName write SetFieldName;
property Font: TFont read GetFont write SetFont stored IsFontStored;
property Footer: TColumnFooterEh read FFooter write SetFooter;
property Footers:TColumnFootersEh read FFooters write SetFooters;
property ImageList: TCustomImageList read FImageList write SetImageList;
property ImeMode: TImeMode read GetImeMode write SetImeMode stored IsImeModeStored;
property ImeName: TImeName read GetImeName write SetImeName stored IsImeNameStored;
property Increment: Extended read FIncrement write FIncrement stored IsIncrementStored;
property KeyList: TStrings read GetKeykList write SetKeykList;
property LookupDisplayFields: String read GetLookupDisplayFields write SetLookupDisplayFields stored IsLookupDisplayFieldsStored;
property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 0;
property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
property NotInKeyListIndex: Integer read FNotInKeyListIndex write SetNotInKeyListIndex default -1;
property PickList: TStrings read GetPickList write SetPickList;
property PopupMenu: TPopupMenu read FPopupMenu write SetPopupMenu;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly stored IsReadOnlyStored;
property Tag: Longint read FTag write FTag default 0;
property Title: TColumnTitleEh read FTitle write SetTitle;
property ToolTips: Boolean read GetToolTips write SetToolTips stored IsToolTipsStored;
property Visible: Boolean read FVisible write SetVisible default True;
property Width: Integer read GetWidth write SetWidth stored IsWidthStored;
property WordWrap: Boolean read GetWordWrap write SetWordWrap stored IsWordWrapStored;
property OnEditButtonClick: TButtonClickEventEh read FOnButtonClick write FOnButtonClick;
property OnEditButtonDown: TButtonDownEventEh read FOnButtonDown write FOnButtonDown;
property OnGetCellParams: TGetColCellParamsEventEh read FOnGetCellParams write SetOnGetCellParams;
property OnNotInList: TNotInListEventEh read FOnNotInList write FOnNotInList;
property OnUpdateData: TColCellUpdateDataEventEh read FUpdateData write FUpdateData;
end;
TColumnEhClass = class of TColumnEh;
{ TDBGridColumnsEh }
TDBGridColumnsEh = class(TCollection)
private
FGrid: TCustomDBGridEh;
function GetColumn(Index: Integer): TColumnEh;
function GetState: TDBGridColumnsState;
function InternalAdd: TColumnEh;
procedure SetColumn(Index: Integer; Value: TColumnEh);
procedure SetState(NewState: TDBGridColumnsState);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
public
constructor Create(Grid: TCustomDBGridEh; ColumnClass: TColumnEhClass);
function Add: TColumnEh;
function ExistFooterValueType(AFooterValueType:TFooterValueType):Boolean;
procedure LoadFromFile(const Filename: string);
procedure LoadFromStream(S: TStream);
procedure RebuildColumns;
procedure RestoreDefaults;
procedure SaveToFile(const Filename: string);
procedure SaveToStream(S: TStream);
property Grid: TCustomDBGridEh read FGrid;
property Items[Index: Integer]: TColumnEh read GetColumn write SetColumn; default;
property State: TDBGridColumnsState read GetState write SetState;
end;
{ TColumnsEhList }
TColumnsEhList = class(TList)
private
function GetColumn(Index: Integer): TColumnEh;
procedure SetColumn(Index: Integer; const Value: TColumnEh);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -