mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 12:19:16 +02:00
IDE, added dbgrid columns component editor at design time, from Leslie Kaye, issue #12941
git-svn-id: trunk@18224 -
This commit is contained in:
parent
3a48aa228b
commit
530feb4ea2
@ -23,7 +23,8 @@ unit DBPropEdits;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, PropEdits, Componenteditors, TypInfo, DB, SysUtils, DBGrids;
|
Classes, ObjInspStrConsts, PropEdits, Componenteditors, TypInfo, DB, SysUtils,
|
||||||
|
DBGrids;
|
||||||
|
|
||||||
type
|
type
|
||||||
TFieldProperty = class(TStringPropertyEditor)
|
TFieldProperty = class(TStringPropertyEditor)
|
||||||
@ -38,6 +39,15 @@ type
|
|||||||
procedure FillValues(const Values: TStringList); override;
|
procedure FillValues(const Values: TStringList); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TDBGridComponentEditor }
|
||||||
|
|
||||||
|
TDBGridComponentEditor = class(TComponentEditor)
|
||||||
|
public
|
||||||
|
function GetVerbCount: Integer; override;
|
||||||
|
function GetVerb(Index: Integer): string; override;
|
||||||
|
procedure ExecuteVerb(Index: Integer); override;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TFieldProperty }
|
{ TFieldProperty }
|
||||||
@ -87,9 +97,33 @@ begin
|
|||||||
DataSource.DataSet.GetFieldNames(Values);
|
DataSource.DataSet.GetFieldNames(Values);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TDBGridComponentEditor }
|
||||||
|
|
||||||
|
function TDBGridComponentEditor.GetVerbCount: Integer;
|
||||||
|
begin
|
||||||
|
Result:= 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDBGridComponentEditor.GetVerb(Index: Integer): string;
|
||||||
|
begin
|
||||||
|
Result:= sccsLvColEdt;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDBGridComponentEditor.ExecuteVerb(Index: Integer);
|
||||||
|
var
|
||||||
|
Hook: TPropertyEditorHook;
|
||||||
|
DBGrid: TDBGrid;
|
||||||
|
begin
|
||||||
|
DBGrid := GetComponent as TDBGrid;
|
||||||
|
GetHook(Hook);
|
||||||
|
EditCollection(DBGrid, DBGrid.Columns, 'Columns');
|
||||||
|
if Assigned(Hook) then Hook.Modified(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TFieldProperty);
|
RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TFieldProperty);
|
||||||
RegisterPropertyEditor(TypeInfo(string), TColumn, 'FieldName', TDBGridFieldProperty);
|
RegisterPropertyEditor(TypeInfo(string), TColumn, 'FieldName', TDBGridFieldProperty);
|
||||||
|
RegisterComponentEditor(TDBGrid,TDBGridComponentEditor);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user