Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CheckBox

Posted on 2001-06-29
12
Medium Priority
?
346 Views
Last Modified: 2010-04-06
How can i check whether they checked or not for about 200 checkboxes?
0
Comment
Question by:systemop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 6

Expert Comment

by:Jaymol
ID: 6238199
Let's pretend that the checkboxes are called chk1 - chk200

For I:=1 to 200 do
  If TCheckBox(FindComponent('chk'+IntToStr(I))).Checked then .......


That's how you do it!

John.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6238203
Or if all the components on the form are checkboxes:

     For i := 0 to ComponentCount - 1 Do
     If (Components[i] is TCheckBox) then
     If (Components[i] as TCheckBox).Checked then...

J.
0
 
LVL 6

Expert Comment

by:edey
ID: 6238238
For so many check boxes one might consider using a different control to help sort them - that's a lot of potential confusion for a user!  Perhaps a treeView with check boxes?

GL
Mike
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:systemop
ID: 6238324
Jaymol thanks for your help but how can i define which checkboxes are checked? ex : i want to give a message for every checked boxes?
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 6238332
What are you actually asking then?

Sorry, but it seems your not asking how to tell if they're checked, but asking how to handle an amount of them being checked.

John.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6238340
One thing to do is give them all a unique number in their Tag property, then you could hold a list of all those checkboxes by tag number whose Checked property is True.

J.
0
 

Author Comment

by:systemop
ID: 6238355
Can you explain with an example jsweby?
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 6238364
Systemop, what are you attempting to achieve?
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6238378
procedure Button1Click(Sender: TObject);
var
   CheckBoxArray: Array[1..200] Of Integer;
   CheckBoxCheckedCount, i: Integer;
begin
    CheckBoxCheckedCount := 0;

    For i := 0 to ComponentCount - 1 Do
    If (Components[i] is TCheckBox) then
    If (Components[i] as TCheckBox).Checked then
    Begin
         inc(CheckBoxCheckedCount);
         CheckBoxArray[CheckBoxCheckedCount] := Components[i] as TCheckBox).Tag;
    End;
end;

Essentially what this will give you is:

(a) the number of checkboxes ticked in the CheckBoxCheckedCount variable
(b) the tag numbers of those check boxes which are ticked in the CheckBoxArray variable.

This is by no means exhaustive or even robust, just an idea...

J.
0
 

Author Comment

by:systemop
ID: 6238380
Summary :

I have 200 checkboxes and one button. Every chckbox has different captions. I check 120 of them. (But they re in different order.) OnButton1.Click i want to write all of the checked CheckBoxes.Caption. Ok Now?
0
 
LVL 4

Accepted Solution

by:
jsweby earned 75 total points
ID: 6238387
Ok, instead then:

procedure Button1Click(Sender: TObject);
begin
   For i := 0 to ComponentCount - 1 Do
   If (Components[i] is TCheckBox) then
   If (Components[i] as TCheckBox).Checked then
   Begin
        ShowMessage((Components[i] as TCheckBox).Caption);
   End;
end;

This will put out a message for each one that is ticked, you may want to output these to a file.

J.
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 6238391
It depends on where you want to write it, but this will create a string with the caption of each checked checkbox.

var
  TmpI  : Integer;
  TmpS  : String;
Begin
  TmpS:='';
  For TmpI:=1 to 200 do
    If TCheckBox(FindComponent('chk'+TmpI)).Checked then begin
      If TmpS<>'' then TmpS:=TmpS+#13;
      TmpS:=TmpS+TCheckBox(FindComponent('chk'+TmpI)).Caption;
    end;
  ShowMessage(TmpS);
End;

John.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question