冗余代码

dongxufeifei 2003-07-19 09:56:10
小弟一个程序中有n个edit控件。现在要实现如下功能,edit1的font由fontdialog1指定,edit2、edit3……等等他们的font也由fontdialog1指定
如果为每一个edit控件编写代码则是一种重复,而且是一种浪费,请问有没有更好的方法实现如上述功能呢?
...全文
56 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
pressman 2003-07-21
  • 打赏
  • 举报
回复
for i:=0 to form.controls.conut do
begin
if control[i] is TEdit then
begin
......
end;
end;
D5 开发人员指南里有很详细的说明
建议去看看!
李_军 2003-07-20
  • 打赏
  • 举报
回复
if fontdialog1.Execute then
for i:=0 to Form1.Componentcount-1 do
if Components[i] is TEdit then
begin
TEdit(Components[i]).Font := fontdialog1.Font;
end;
dongfang73 2003-07-20
  • 打赏
  • 举报
回复
for i:=0 to form.controls.conut do
begin
if control[i] is TEdit then
begin
......
end;
end;
dongfang73 2003-07-20
  • 打赏
  • 举报
回复
for i:=0 to componentcount-1 do
if components[i] is tedit then
begin
end
foxlord 2003-07-20
  • 打赏
  • 举报
回复
写一个函数
function fontset(pEdit:TEdit):TFont;
每一个Edit调用此函数就可以了
thh820630 2003-07-20
  • 打赏
  • 举报
回复
如果你想都一样的话那你就设你的控件所在的窗体吧
如果不想可试试这个
for i:=0 to form.controls.conut do
begin
if control[i] is TEdit then
begin
......
end;
end;
yl_588888 2003-07-19
  • 打赏
  • 举报
回复
for i;=0 to form.controls.count do
begin
if form.controls[i] is tedit then
begin
end;
end;

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧