给值指定多个编辑框的名称 [英] Assign values to multiple edit boxes, given their names

查看:56
本文介绍了给值指定多个编辑框的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Borland C ++ Builder 6中进行一些编程。

i am currently doing some programming in Borland C++ Builder 6.

我有24个编辑框(一个可视组件,带有文本字段),我想插入框中的一些值,现在我是这样的:

I have 24 edit boxes(a visual component, with a text field) and i want to insert some values in the boxes, now i do it like this:

Edit1->Text=1;
Edit2->Text=2;
Edit3->Text=3;
...
Edit24->Text=24;

但是我想要这样的东西:

but i want to have something like this:

for(int i=1; i<25;i++){
Edit"i"->Text=i;
}

我认为我必须制作一系列对象或东西。
有人可以帮助我吗?我对类似的东西没有太多的经验。

i think i have to make an array of objects or something. Can any body help me with this? I don't have a lot of experience with objects and stuff like that.

推荐答案

VCL中有一个 FindComponent 函数。

There is a FindComponent function in VCL. It is used to find a component by it's name.

在您的情况下,它将类似于:

In your case it will look something like:

TEdit * tmp;
for( int i = 0; i < 24; i ++ )
{
    tmp = (TEdit*)MyForm->FindComponent("Edit" + IntToStr(i) );
    tmp->Text = i;
}

这篇关于给值指定多个编辑框的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆