I
iambox
Unregistered / Unconfirmed
GUEST, unregistred user!
如下代码(部分)中,“DataSource := GetPropertyValue(GetComponent(0), GetDataS
ourcePropName) as TDataSource;”这句中的GetPropertyValue说找不到,请问应该用何
种函数替代?谢谢。
TListFieldProperty = class(TStringProperty) //继承于TStringProperty,因为Fiel
dName是字符串
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings); virtual;
procedure GetValues(Proc: TGetStrProc); override;
function GetDataSourcePropName: string; virtual;
end;
{ TListFieldProperty }
function TListFieldProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;
function TListFieldProperty.GetDataSourcePropName: string;
begin
Result := 'DataSource'; //指定字段下拉列表到什么属性里取值
end;
procedure TListFieldProperty.GetValueList(List: TStrings);
var
DataSource: TDataSource;
begin
//从上述GetDataSourcePropName方法指定的属性去取出所有字段用来下拉显示
//因为在本控件中定义的属性是TDataSource 所以这里用TDataSource, 如果是TAdoQue
ry, 或者其他派生于
//TDataSet类的这里就只需要点定义一个DataSet 而不需要TDataSource了
DataSource := GetPropertyValue(GetComponent(0), GetDataSourcePropName) as TDa
taSource;
if (DataSource <> nil) and (DataSource.DataSet <> nil) then
DataSource.DataSet.GetFieldNames(List);
end;
procedure TListFieldProperty.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);
finally
Values.Free;
end;
end;
ourcePropName) as TDataSource;”这句中的GetPropertyValue说找不到,请问应该用何
种函数替代?谢谢。
TListFieldProperty = class(TStringProperty) //继承于TStringProperty,因为Fiel
dName是字符串
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings); virtual;
procedure GetValues(Proc: TGetStrProc); override;
function GetDataSourcePropName: string; virtual;
end;
{ TListFieldProperty }
function TListFieldProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;
function TListFieldProperty.GetDataSourcePropName: string;
begin
Result := 'DataSource'; //指定字段下拉列表到什么属性里取值
end;
procedure TListFieldProperty.GetValueList(List: TStrings);
var
DataSource: TDataSource;
begin
//从上述GetDataSourcePropName方法指定的属性去取出所有字段用来下拉显示
//因为在本控件中定义的属性是TDataSource 所以这里用TDataSource, 如果是TAdoQue
ry, 或者其他派生于
//TDataSet类的这里就只需要点定义一个DataSet 而不需要TDataSource了
DataSource := GetPropertyValue(GetComponent(0), GetDataSourcePropName) as TDa
taSource;
if (DataSource <> nil) and (DataSource.DataSet <> nil) then
DataSource.DataSet.GetFieldNames(List);
end;
procedure TListFieldProperty.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);
finally
Values.Free;
end;
end;