?
Solved

Having problems with  Groupbox and RadioBoxes...

Posted on 2003-03-10
7
Medium Priority
?
301 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
[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
7 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
Industry Leaders: 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

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!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

765 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