Creating Control Array in Borland C++ Builder 6.0

M

Mani

Hi,
can anyone help me on how to create a control array in C++ builder
like we create in VB.
I have another question regarding controls. I want to clear a group
of text boxes in the form on a button click. I am not using any
groupbox. how can i determine the control as Editbox and how can i
clear that.
any help would be appreciated.
thanx
 
D

David B. Held

Mani said:
can anyone help me on how to create a control array in
C++ builder like we create in VB.
[...]

Point your newsreader at forums.borland.com or
news.borland.com and subscribe to borland.public.cppbuilder.
vcl.using.

Dave
 
T

Thomas Matthews

Mani said:
Hi,
can anyone help me on how to create a control array in C++ builder
like we create in VB.

Read the FAQ about arrays. You can use an array or a vector.
Example:
Control my_controls[50]; // an array of 50 Controls.
std::vector<Control> my_other_controls; // A vector of Controls.

If there is a parent class, then you can have an array of pointers
to controls, and put in pointers to child classes:
class Button_Control
: public Control
{
// ...
}; /* a Button_Control _is_a_ Control */

std::vector<Control *> my_control_ptrs; // Vector of Control ptrs.

Now if the Control class had a clear() method, you could do:
my_control_ptrs[0]->clear(); // Tell the first Control to clear.
or
for (unsigned int i = 0; i < my_controls_ptrs.size(); ++i)
{
my_control_ptrs->clear();
}
for telling all the Controls to clear.

My brain is foggy at the moment, so I suggest you look at your C++
text book, compiler help manuals or the C++ FAQ for information
on declaring arrays of pointers.

I have another question regarding controls. I want to clear a group
of text boxes in the form on a button click. I am not using any
groupbox. how can i determine the control as Editbox and how can i
clear that.

Your other question is off-topic for this newsgroup. I have shown
how one method can be executed for a vector of objects. My intuition
says that the process is very similar.
any help would be appreciated.
thanx


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top