By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

How to dynamically create and bind radio buttons in Windows form - VB.NET

P: n/a
Help,

I need to display radio buttons on a form. The data is from SQL
table: each row in each table is displayed as a radio button. I have
multiple SQL tables so I understand I need to put them each in a
GroupBox. All the examples I saw from the books or from the web show
me how to add static radio buttons at design, or dynamically at run
time but with fixed radio buttons (like from an array).

I need to create radio buttons based on the data I have from my SQL
table. This data could be altered by the users. Therefore, if I
create fixed radio buttons, every time the user add a new row or
delete a row, that means I have to go to change it in design or in
code. It's not a practical practice.

Anybody has any examples or any advices? Thank you.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You will have to create the buttons and add the to the form at run time. If
you look in the "designer generated code" you will see what VS does to add a
radio button to the form. You just have to do this for each row you want a
radio button created for. Just remember to adjust the size of your group
box for however many radio buttons you add. If I remember correctly (I
haven't checked this) you have to add the radio button the to the controls
object of the group box. but like I said, check out the designer generated
code for an example of adding a radio button to a form/group box

Hope this helps.
Chris
"James P." <ha*********@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
Help,

I need to display radio buttons on a form. The data is from SQL
table: each row in each table is displayed as a radio button. I have
multiple SQL tables so I understand I need to put them each in a
GroupBox. All the examples I saw from the books or from the web show
me how to add static radio buttons at design, or dynamically at run
time but with fixed radio buttons (like from an array).

I need to create radio buttons based on the data I have from my SQL
table. This data could be altered by the users. Therefore, if I
create fixed radio buttons, every time the user add a new row or
delete a row, that means I have to go to change it in design or in
code. It's not a practical practice.

Anybody has any examples or any advices? Thank you.

Nov 21 '05 #2

P: n/a

Chris wrote:
You will have to create the buttons and add the to the form at run time. If you look in the "designer generated code" you will see what VS does to add a radio button to the form. You just have to do this for each row you want a radio button created for. Just remember to adjust the size of your group box for however many radio buttons you add. If I remember correctly (I haven't checked this) you have to add the radio button the to the controls object of the group box. but like I said, check out the designer generated code for an example of adding a radio button to a form/group box

Hope this helps.
Chris
"James P." <ha*********@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
Help,

I need to display radio buttons on a form. The data is from SQL
table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put them each in a
GroupBox. All the examples I saw from the books or from the web show me how to add static radio buttons at design, or dynamically at run
time but with fixed radio buttons (like from an array).

I need to create radio buttons based on the data I have from my SQL
table. This data could be altered by the users. Therefore, if I
create fixed radio buttons, every time the user add a new row or
delete a row, that means I have to go to change it in design or in
code. It's not a practical practice.

Anybody has any examples or any advices? Thank you.


Chris,

Thank you for your suggestion. Are there anyway I can write code to
create those radio buttons based on data in SQL so that it
automatically creates the buttons without me manually write code to
create each and every single button for each row (a description field)
in design or "designer generated code"?

Thank you,
James

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.