radio button

  • Thread starter Thread starter juli
  • Start date Start date
J

juli

Hello,
I have a group box and I want to present there radio buttons.
The source for the text of the radio buttons is from a collection.
That's the code:

foreach (Performance p in re.PL)
{
RadioButton radio=new RadioButton();
radio.Text=p.Class_Name;
this.groupBox1.Controls.Add(radio);

}

The problem is that I get only one radio button presented in a group
box although supposed to be much more.Do you know why?:)
 
You get more than one but you didn't set the location of the buttons, so they
all go to [0,0] so you see only one!
Make another variable in the loop that will help you to set the Location.Y
property.
 
Hello,
Thanks but I am trying to increase the radio.Location.Y value with no
success,the compiler writes:

Cannot modify the return value of
'System.Windows.Forms.Control.Location' because it is not a variable

How exactly do I change it?
Thanks!
 
radio.Location = new System.Drawing.Point(x, y)

It's always a good idea to look at the hidden code of the designer and find
out how to do it.
 
Hei,
I added an int i to the loop and did :

radio.Location = new System.Drawing.Point(i,i)
each time incresing the i value but I still see only one radio button on
the group box control.Why?
Thanks!
 
Try to debug your code. Put after the loop a breakpoint. How much objects do
you see in GroupBox.Controls? As you expect, or only one?
 
Back
Top