Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Having problems with  Groupbox and RadioBoxes...

Posted on 2003-03-10
7
Medium Priority
?
314 Views
Last Modified: 2010-05-18
I am having problems understand about the groupbox. In particular, I am trying to attach Radio Buttons to the group box on the form. I am new to this, so please bear with me.

Here is the sample code I am trying to get to work(in the main code section):
rocedure TForm1.ChangeText(Sender: TObject);
var
  Phrase: string;
  I: integer;
begin
  { look at which radio button is selected
  and add its text to the phrase }
  for I := 0 to GroupBox1.ControlCount - 1 do
    if (GroupBox1.Controls[I] as TRadioButton).Checked then
      Phrase := (GroupBox1.Controls[I] as TRadioButton).Caption;

  { add the verb and blank spaces }
  Phrase := Phrase + ' is ';

  { repeat the operation on the second group box }
  for I := 0 to GroupBox2.ControlCount - 1 do
    with GroupBox2.Controls[I] as TRadioButton do
      if Checked then
        Phrase := Phrase + Caption;

  { retrieve the radio group selection, and display
  the result in the label }
  Label1.Caption := Phrase + ' ' +
    RadioGroup1.Items[RadioGroup1.ItemIndex];
end;
Basically, there are two GroupBoxes and one RadioBox on the Form and it's supposed to be sample source code demonstrating how groupboxes and radioboxes work. The thing I'm trying to do, which it won't allow me to do, is have the "Checked" property on both groupboxes(GroupBox1 and GroupBox2). So, it doesn't have any values to calculate. Also, I debugged it and noticed that there is no value for "GroupBox1.ControlCount", so it is not even performing the code. I think the Radio buttons are somehow not linked to the groupbox. My question in that case is, how do I link the Radio Buttons to the form, so it will show some values in the debbuging process? Thx for all the help!
0
Comment
Question by:smilley654
6 Comments
 

Author Comment

by:smilley654
ID: 8108536
For more information on where I received the source code, please refer to:
http://www.macrocantu.com/edelphi

respectfully, entitled, "Essential Delphi"(page 91)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8109171
seems to be a design-error

just drop first the groupbox and
then the tradios into the groupbox and not otherwise

(-> frist dropping the tradios and then frame it
with a tgroupbox will cause that the radios are not
member of the groupbox)

you can test it by moving the groupbox at designmode,
if the radios don't move with the groupbox, than they are not member of it)

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 8109173
btw. the link above doesn't work
0
Technology Partners: 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!

 
LVL 21

Assisted Solution

by:ziolko
ziolko earned 100 total points
ID: 8109182
If You use only RadioButtons use TRadioGroup:


 { look at which radio button is selected
 and add its text to the phrase }
 for I := 0 to RadioGroup1.Items.Count - 1 do
   if TRadioButton(RadioGroup1.Controls[I]).Checked then
     Phrase := RadioGroup1.Items[I];

 { add the verb and blank spaces }
 Phrase := Phrase + ' is ';

 { repeat the operation on the second group box }
 for I := 0 to RadioGroup2.Items.Count - 1 do
   if TRadioButton(RadioGroup2.Controls[I]).Checked then
       Phrase := Phrase + Caption;

 { retrieve the radio group selection, and display
 the result in the label }
 Label1.Caption := Phrase + ' ' +
   RadioGroup1.Items[RadioGroup1.ItemIndex];


ziolko.
0
 

Expert Comment

by:CleanupPing
ID: 9316848
smilley654:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 10091026
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Split between kretzschmar and ziolko

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer
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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

571 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