// 返回_strSource 在 _strDest列表 中的索引号
function IndexOfList( _strSource, _strDest:string; _strDelimiter: char=';'): Integer;
var sltDest: TStrings;
begin
_strSource := LowerCase(_strSource);
_strDest := LowerCase(_strDest); sltDest:= TStringList.Create;
try
sltDest.Delimiter := _strDelimiter;
sltDest.DelimitedText := _strDest;
Result := sltDest.IndexOf( _strSource );
finally
sltDest.Free;
end;
end;
// 设置组件的属性
// :: objOwer 拥有组件的窗体对象; _strCompList 需要设置属性的组件列表; _strProperty 属性名称; _strValue 要设置的属性值; _strDelimiter 组件列表的分割符号
// 调用格式: SetCompProp( MainForm, 'edit1;edit2;edit5', 'readonly', 'true')function SetCompProp( _objOwer: TForm; _strCompList, _strProperty, _strValue: string; _strDelimiter: char=';'): boolean;
var sltDest: TStrings;
intIndex: Integer;
objComp: TComponent;
strClsName: string;
begin
sltDest:= TStringList.Create;
try
sltDest.Delimiter := _strDelimiter;
sltDest.DelimitedText := _strCompList; for intIndex := 0 to sltDest.Count -1 do
begin
objComp := _objOwer.FindComponent(sltDest.Strings[intIndex]);
if not assigned(objComp) then
continue; strClsName := objComp.ClassName; case IndexOfList(strClsName, 'TEdit;TComboBox;TLabel;TRichEdit;TButton;TSpeedButton;TToolButton' ) of
0: begin // tedit
// ??? 请高手指点下,如何动态的设置组建的属性,如上面的调用示范:edit1.readonly 属性?
end;
1: begin // TComboBox end;
2: begin // TLabel end;
3: begin // TRichEdit end;
4: begin // TButton end;
5: begin // TSpeedButton end;
6: begin // TToolButton end;
else
end;
end;
finally
sltDest.Free;
end;
end;
在此感谢!或者您有更好的方法,还请赐教 :)
function IndexOfList( _strSource, _strDest:string; _strDelimiter: char=';'): Integer;
var sltDest: TStrings;
begin
_strSource := LowerCase(_strSource);
_strDest := LowerCase(_strDest); sltDest:= TStringList.Create;
try
sltDest.Delimiter := _strDelimiter;
sltDest.DelimitedText := _strDest;
Result := sltDest.IndexOf( _strSource );
finally
sltDest.Free;
end;
end;
// 设置组件的属性
// :: objOwer 拥有组件的窗体对象; _strCompList 需要设置属性的组件列表; _strProperty 属性名称; _strValue 要设置的属性值; _strDelimiter 组件列表的分割符号
// 调用格式: SetCompProp( MainForm, 'edit1;edit2;edit5', 'readonly', 'true')function SetCompProp( _objOwer: TForm; _strCompList, _strProperty, _strValue: string; _strDelimiter: char=';'): boolean;
var sltDest: TStrings;
intIndex: Integer;
objComp: TComponent;
strClsName: string;
begin
sltDest:= TStringList.Create;
try
sltDest.Delimiter := _strDelimiter;
sltDest.DelimitedText := _strCompList; for intIndex := 0 to sltDest.Count -1 do
begin
objComp := _objOwer.FindComponent(sltDest.Strings[intIndex]);
if not assigned(objComp) then
continue; strClsName := objComp.ClassName; case IndexOfList(strClsName, 'TEdit;TComboBox;TLabel;TRichEdit;TButton;TSpeedButton;TToolButton' ) of
0: begin // tedit
// ??? 请高手指点下,如何动态的设置组建的属性,如上面的调用示范:edit1.readonly 属性?
end;
1: begin // TComboBox end;
2: begin // TLabel end;
3: begin // TRichEdit end;
4: begin // TButton end;
5: begin // TSpeedButton end;
6: begin // TToolButton end;
else
end;
end;
finally
sltDest.Free;
end;
end;
在此感谢!或者您有更好的方法,还请赐教 :)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货