Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

checkbox in C++ Builder

Status
Not open for further replies.

Eugen_E

Full Member level 6
Full Member level 6
Joined
Nov 29, 2004
Messages
387
Helped
44
Reputation
86
Reaction score
11
Trophy points
1,298
Location
Romania
Activity points
2,878
How I can generate an "array" of checkboxes in C++ Builder?
The size of the array is determined at runtime, like this:

columns
Ξ Ξ Ξ
Ξ Ξ Ξ
Ξ Ξ Ξ
Ξ Ξ Ξ rows Ξ - checkbox

The tutorials I read only show how to put the checkboxes at design time, using the editor and object inspector. I don't know many things about object programming and C++ Builder, but I need to do a very, very simple project.
Thanks for your help.
 

Probably you can obtain Xmin, XMax, YMin and YMax coordinates for your area.
For example you have to create three (N=3) rows of checkboxes. Then you should to calculate

x_step = (XMax - XMin)/N;
First column will start from x = XMin the second - from XMin + x_step, and the third - from XMin + 2*x_step (this is equal to XMax)
Do the same about Y coordinates.

And then just run loops.
for(y = YMax; y >= YMin; y-=y_step)
for(x = XMin; x <= XMax; x+= x_step)
{
// Here you create checkbox and move if to x, y
}

Looks like it's the best solution for you.
 

    Eugen_E

    Points: 2
    Helpful Answer Positive Rating
Sorry,
actually I don't know how to create a checkbox in code. I only know to put the checkbox on the form with the mouse , from the controls available.
 

Problem solved, a checkbox can be created in code, with something like this:

TCheckBox* MyCheckBox[max_lines][max_cols];

for(y = YMax,i=0; y >= YMin; y-=y_step,i++)
for(x = XMin,j=0; x <= XMax; x+= x_step,j++)
{
MyCheckBox[j]=new TCheckBox(this);
MyCheckBox->Parent=Form1;
MyCheckBox->Left=x;
MyCheckBox->Top=y;
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top