radio button

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?:)
 
G

Guest

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.
 
J

juli jul

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!
 
G

Guest

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.
 
J

juli jul

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!
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top