当前位置:主页>销售管理软件> 列表

如何给一个form中所有控件赋值 找最好的进销存软件

进销存软件版1楼: 如何给一个form中所有控件赋值?比如我要将所有控件的Caption赋值为“检查”,如何做?

2楼: procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=0 to Self.ComponentCount -1 do
if (Self.Components[i] is TLabel) then
(Self.Components[i] as TLabel).Caption := ''检查'' ;
end; 如进销存系统

3楼: procedure TForm1.CleanControl(myControl:TWinControl);
var
i:integer;
begin
if myControl.ControlCount = 0 then
begin
if myControl is TEdit then
TEdit(myControl).Text :=''''
else if myControl is TCombobox then
TCombobox(myControl).ItemIndex :=0
else if myControl is TMemo then
TMemo(myControl).Text :=''''
else if myControl is TMaskEdit then
TMaskEdit(myControl).Text :=''''
else if myControl is TLabeledEdit then
TLabeledEdit(myControl).Text :=''''
else if myControl is TDateTimePicker then


TDateTimePicker(myControl).DateTime := now ;
end
else
begin
for i:= 0 to myControl.ControlCount - 1 do
if (myControl.controls[i] is TForm) or
(myControl.controls[i] is TPanel) or
(myControl.controls[i] is TPageControl) or
(myControl.controls[i] is TTabControl) or
(myControl.controls[i] is TGroupBox) or
(myControl.controls[i] is TEdit) or
(myControl.controls[i] is TCombobox) or
(myControl.controls[i] is TMemo) or
(myControl.controls[i] is TMaskEdit) or
(myControl.controls[i] is TLabeledEdit) or
(myControl.controls[i] is TDateTimePicker) then
CleanControl(Twincontrol(myControl.controls[i]));
end;
end;
这是一个递归整理界面的程序,你改造一下就可以了

4楼: weichao9999:你的是列出了所有的控件类型一一赋值,有没有什么办法可以不要一一列出所有控件?

5楼: 不行吧,因为不知道一个控件具体类型的话是不能确定它是不是有caption这个属性的。
你可以根据你的实际情况对你要赋值控件进行选择,然后改造那个递归函数,

6楼: 没办法,不是所有控件都有caption属性,有caption属性的控件又不是从同一个父类里继承的(比如Tlabel和Tedit)

进销存软件版7楼: var i:integer;
begin
for i:= 0 to self.ComponentCount-1 do
TControl(self.Components[i]).SetTextBuf(''union text'');
end

8楼: anso的解答不错,又简洁~~支持

9楼: 我用的是BussinessSkin控件,我要把Form中所有的控件的SkinData属性设置为公共窗体FrDM中的bsSkinData1,请问怎么做?

10楼: 汗,第3方控件....

11楼: 哈哈 搞定,刚试了 没问题

var
i:integer;
PropInfo:PPropInfo;
begin
for i:=0 to self.ComponentCount-1 do
try
PropInfo:=GetPropInfo(Components[i],''SkinData'');
if propinfo<>nil then
SetOrdProp(Components[i],''SkinData'',integer(bsSkinData1));
except
end;
end;

给分吧,不过10分少了点。。。。。。嘿嘿。。。。。。。

12楼: 谢谢 如最好的进销存软件