delphi中实现用字符串表示并操作控件的方法。
2006-05-13 17:39
706 查看
下面代码用字符串实现了对控件的操作,其中所有控件都在panel1内,
StrEdtProNum代表Tedit控件EdtProNum,其它同。
procedure TPM_FrmCFProPlan_Mon.CbUseMatUnit_1Change(Sender: TObject);
var
StrEdtProNum:String;
StrEdtClassNum:String;
StrEdtMatNum:String;
StrCbUseMat:String;
begin
try
StrEdtProNum:='';
StrEdtClassNum:='';
StrEdtMatNum:='';
StrCbUseMat:='';
i:=1;
for i:=1 to 15 do
begin
StrCbUseMat:='CbUseMatUnit_'+InttoStr(i)+'';
StrEdtProNum:='EdtProNum_'+InttoStr(i)+'';
StrEdtClassNum:='EdtClassNum_'+InttoStr(i)+'';
StrEdtMatNum:='EdtMatNum_'+InttoStr(i)+'';
//Compute Values of ProNum1 ClassNum1 and MatNum1
if TComboBox(Panel1.FindChildControl(StrCbUseMat)).Text='公司' then
begin
EdtProNum1.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtProNum)).Text)+Strtofloat(EdtProNum1.Text)));
EdtClassNum1.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtClassNum)).Text)+Strtofloat(EdtClassNum1.Text)));
EdtMatNum1.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtMatNum)).Text)+Strtofloat(EdtMatNum1.Text)));
end;
//Compute Values of ProNum2 ClassNum2 and MatNum2
if TComboBox(Panel1.FindChildControl(StrCbUseMat)).Text='住金公司' then
begin
EdtProNum2.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtProNum)).Text)+Strtofloat(EdtProNum2.Text)));
EdtClassNum2.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtClassNum)).Text)+Strtofloat(EdtClassNum2.Text)));
EdtMatNum2.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtMatNum)).Text)+Strtofloat(EdtMatNum2.Text)));
end;
end;
except
ShowMessage('输入数据格式不正确 ,请重新输入!')
end;
end;
StrEdtProNum代表Tedit控件EdtProNum,其它同。
procedure TPM_FrmCFProPlan_Mon.CbUseMatUnit_1Change(Sender: TObject);
var
StrEdtProNum:String;
StrEdtClassNum:String;
StrEdtMatNum:String;
StrCbUseMat:String;
begin
try
StrEdtProNum:='';
StrEdtClassNum:='';
StrEdtMatNum:='';
StrCbUseMat:='';
i:=1;
for i:=1 to 15 do
begin
StrCbUseMat:='CbUseMatUnit_'+InttoStr(i)+'';
StrEdtProNum:='EdtProNum_'+InttoStr(i)+'';
StrEdtClassNum:='EdtClassNum_'+InttoStr(i)+'';
StrEdtMatNum:='EdtMatNum_'+InttoStr(i)+'';
//Compute Values of ProNum1 ClassNum1 and MatNum1
if TComboBox(Panel1.FindChildControl(StrCbUseMat)).Text='公司' then
begin
EdtProNum1.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtProNum)).Text)+Strtofloat(EdtProNum1.Text)));
EdtClassNum1.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtClassNum)).Text)+Strtofloat(EdtClassNum1.Text)));
EdtMatNum1.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtMatNum)).Text)+Strtofloat(EdtMatNum1.Text)));
end;
//Compute Values of ProNum2 ClassNum2 and MatNum2
if TComboBox(Panel1.FindChildControl(StrCbUseMat)).Text='住金公司' then
begin
EdtProNum2.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtProNum)).Text)+Strtofloat(EdtProNum2.Text)));
EdtClassNum2.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtClassNum)).Text)+Strtofloat(EdtClassNum2.Text)));
EdtMatNum2.Text:=InttoStr(Round(Strtofloat(TEdit(Panel1.FindChildControl(StrEdtMatNum)).Text)+Strtofloat(EdtMatNum2.Text)));
end;
end;
except
ShowMessage('输入数据格式不正确 ,请重新输入!')
end;
end;
相关文章推荐
- 【廖雪峰 python教程 课后题 切片】利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法:
- delphi 操作 TWebBrowser 实现自动填表(JQuery脚本与 OleVariant 方法)
- 用DELPHI、RxRichEdit控件实现类似QQ的表情输入方法
- Delphi开发环境下利用Spcomm控件实现PC机与单片机之间串口通信的方法
- delphi中执行字符串表示的方法名
- c语言自定义方法实现字符串的7个操作
- Delphi开发环境下利用Spcomm控件实现PC机与单片机之间串口通信的方法
- 读书随码《php核心技术与最佳实践》 魔术方法__call()实现字符串链式操作
- Python对字符串实现去重操作的方法示例
- UNIX常用的IP表示掩码方式转换为字符串的程序实现方法
- 字符串操作函数的实现方法(代码)
- C字符串操作函数实现方法小结
- C# :线程中操作多控件 (委托实现异步及同步的方法)
- Winform分页控件支持表头全选操作实现之最优方法
- javascript实现的字符串与十六进制表示字符串相互转换方法
- SQL Server实现将特定字符串拆分并进行插入操作的方法
- 【廖雪峰 python教程 课后题 切片】利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法:
- Delphi控件TEdit只接受数字键和退格键的实现方法
- 用Delphi实现文件下载的几种方法(三种使用控件的方法)
- delphi 操作 TWebBrowser 实现自动填表(JQuery脚本与 OleVariant 方法)