Click here to Skip to main content
15,889,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form in which there are 7 questions. The questions are displayed on the form using dataset containing a table of questions and answers.
In the dataset items 0, 1,2,3,4 contains the question number, question, first option, second option and third option respectively.
I want to know if there is a better way of loading the questions.
I have grouped the radio buttons into sets of three using GroupBox.
VB
Label2.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label1.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton1.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton2.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton3.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1

         Label4.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label3.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton4.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton5.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton6.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1

         Label5.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label6.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton7.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton8.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton9.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1


         Label15.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label8.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton10.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton11.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton12.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1


         Label9.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label10.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton13.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton14.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton15.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1

         Label11.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label12.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton16.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton17.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton18.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1

         Label13.Text = ds.Tables("AddressBook").Rows(a).Item(0)
         Label14.Text = ds.Tables("AddressBook").Rows(a).Item(1)
         RadioButton19.Text = ds.Tables("AddressBook").Rows(a).Item(2)
         RadioButton20.Text = ds.Tables("AddressBook").Rows(a).Item(3)
         RadioButton21.Text = ds.Tables("AddressBook").Rows(a).Item(4)
         a = a + 1
Posted
Updated 21-Apr-13 21:42pm
v2

1 solution

Since you are going to show the question multiple time then I suggest you to create your own User Control.

Inside the user control you can put 2 labels for the number and question and three radio button for the options. Then include class properties to keep the questions number and options.You can also program more actions inside the control.

After building the project, you should be able to drag and drop the control into the form.

More tutorial on how to make the controls here
Making A User Control
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900