TDBStringProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings); virtual;
procedure GetValues(Proc: TGetStrProc); override;
end;
TDataFieldProperty = class(TDBStringProperty)
public
function GetDataSourcePropName: string; virtual;
procedure GetValueList(List: TStrings); override;
end;
{ TDBStringProperty }
function TDBStringProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;
procedure TDBStringProperty.GetValueList(List: TStrings);
begin
end;
procedure TDBStringProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Values: TStringList;
begin
Values := TStringList.Create;
try
GetValueList(Values);
for I := 0 to Values.Count - 1 do Proc(Values[I]);
finally
Values.Free;
end;
end;
function GetIndexDefs(Component: TPersistent): TIndexDefs;
var
DataSet: TDataSet;
begin
DataSet := Component as TDataSet;
Result := GetObjectProp(DataSet, 'IndexDefs') as TIndexDefs;
if Assigned(Result) then
begin
Result.Updated := False;
Result.Update;
end;
end;
{ TDataFieldProperty }
function TDataFieldProperty.GetDataSourcePropName: string;
begin
Result := 'DataSource';
end;
procedure TDataFieldProperty.GetValueList(List: TStrings);
var
DataSource: TDataSource;
begin
DataSource := GetObjectProp(GetComponent(0), GetDataSourcePropName) as TDataSource;
if (DataSource <> nil) and (DataSource.DataSet <> nil) then
DataSource.DataSet.GetFieldNames(List);
end;
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings); virtual;
procedure GetValues(Proc: TGetStrProc); override;
end;
TDataFieldProperty = class(TDBStringProperty)
public
function GetDataSourcePropName: string; virtual;
procedure GetValueList(List: TStrings); override;
end;
{ TDBStringProperty }
function TDBStringProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;
procedure TDBStringProperty.GetValueList(List: TStrings);
begin
end;
procedure TDBStringProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Values: TStringList;
begin
Values := TStringList.Create;
try
GetValueList(Values);
for I := 0 to Values.Count - 1 do Proc(Values[I]);
finally
Values.Free;
end;
end;
function GetIndexDefs(Component: TPersistent): TIndexDefs;
var
DataSet: TDataSet;
begin
DataSet := Component as TDataSet;
Result := GetObjectProp(DataSet, 'IndexDefs') as TIndexDefs;
if Assigned(Result) then
begin
Result.Updated := False;
Result.Update;
end;
end;
{ TDataFieldProperty }
function TDataFieldProperty.GetDataSourcePropName: string;
begin
Result := 'DataSource';
end;
procedure TDataFieldProperty.GetValueList(List: TStrings);
var
DataSource: TDataSource;
begin
DataSource := GetObjectProp(GetComponent(0), GetDataSourcePropName) as TDataSource;
if (DataSource <> nil) and (DataSource.DataSet <> nil) then
DataSource.DataSet.GetFieldNames(List);
end;