Create a grid of radiobutton on the fly
-
Hi, I have this problem that requires different areas (30x40, 10x40) of radio buttons. How can I do this on the fly? I can't figure out how can I create the radio buttons and add them to the panel using a for loop? I want to name the radio buttons rb_1_1, rb_1_2 or rb11, rb12, etc. I know I have to create the radio button objects -> RadioButton rb_1_1 = new RadioButton() but how would I change the rb_1_1 when it loops again? Thanks. Desmond
-
Hi, I have this problem that requires different areas (30x40, 10x40) of radio buttons. How can I do this on the fly? I can't figure out how can I create the radio buttons and add them to the panel using a for loop? I want to name the radio buttons rb_1_1, rb_1_2 or rb11, rb12, etc. I know I have to create the radio button objects -> RadioButton rb_1_1 = new RadioButton() but how would I change the rb_1_1 when it loops again? Thanks. Desmond
-
Desmond Lim, http://msdn2.microsoft.com/en-us/library/system.windows.forms.radiobutton.aspx[^] Regards, Gareth.
Sorry Gareth, that's not want I wanted. I know I can do it that way but what if I have 1000 radio buttons I want to create, RadioButton rb_1_1 = new RadioButton(); RadioButton rb_1_2 = new RadioButton(); and so on for 1000 times. Is there a way to do it programmatically, so that I can just create a for loop and it creates the radio buttons for me? And I need to do this in windows not ASP.net (I can do it in ASP.net). Thanks. Desmond
-
Sorry Gareth, that's not want I wanted. I know I can do it that way but what if I have 1000 radio buttons I want to create, RadioButton rb_1_1 = new RadioButton(); RadioButton rb_1_2 = new RadioButton(); and so on for 1000 times. Is there a way to do it programmatically, so that I can just create a for loop and it creates the radio buttons for me? And I need to do this in windows not ASP.net (I can do it in ASP.net). Thanks. Desmond
-
Desmond Lim, Just do:
for (int i = 0; i < 1000; i++)
{
//create controls
}Why do you want to create 1000 radio buttons? Can you give a bit more info on what your trying to do because there might be a better way around it. Regards, Gareth.
I'm creating a software that allows the user to enter data for research purposes. The slide/grid they use comes in different sizes, 20x30, 40x40, 100x30, etc. They want to be able to choose the size (by list box) and when a particular size is chosen, the grid of radio buttons corresponding to the size that they want will be created i.e. if they choose 20x30, 20 columns by 30 rows of radio buttons will be created. The radio buttons will then be use to enter the data that corresponds to that part of the grid, that is to say, when the user clicks the Col 2 and Row 3 radio button, a window might pop up with the information needed for that part. Which means that each individual radio button has to be identifiable. So back to my question how do you do a create radio button with different IDs because I know that when you do a RadioButton rb01 = new RadioButton(); it creates the radio button object, I just don't know how to create radio buttons that have different IDs, i.e. rb01, rb02, rb03, etc. via using a loop. I know that if I do something like
for (int i = 0; i < 1000; i++) { RadioButton rbNew = new RadioButton(); (move rbNew to a particular x y coordinate); rbNew.name = "rb01"; }
This doesn't seem to work for I only get 1 radio button. If you can think another way to do this, I'll really appreciate it. Thanks. Desmond -
I'm creating a software that allows the user to enter data for research purposes. The slide/grid they use comes in different sizes, 20x30, 40x40, 100x30, etc. They want to be able to choose the size (by list box) and when a particular size is chosen, the grid of radio buttons corresponding to the size that they want will be created i.e. if they choose 20x30, 20 columns by 30 rows of radio buttons will be created. The radio buttons will then be use to enter the data that corresponds to that part of the grid, that is to say, when the user clicks the Col 2 and Row 3 radio button, a window might pop up with the information needed for that part. Which means that each individual radio button has to be identifiable. So back to my question how do you do a create radio button with different IDs because I know that when you do a RadioButton rb01 = new RadioButton(); it creates the radio button object, I just don't know how to create radio buttons that have different IDs, i.e. rb01, rb02, rb03, etc. via using a loop. I know that if I do something like
for (int i = 0; i < 1000; i++) { RadioButton rbNew = new RadioButton(); (move rbNew to a particular x y coordinate); rbNew.name = "rb01"; }
This doesn't seem to work for I only get 1 radio button. If you can think another way to do this, I'll really appreciate it. Thanks. Desmond