Select Categories Below
Advertisement
Start Your Own Q&A Site
Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.
Status: Open Points: 125 Time: 07:16 - Jul 22, 2010
kavyagannarapu
hi i am preparing question pool of multiple choice questions ,for that case i need to add many radio buttons suggest me
Categories:
Add Categories
When adding more than one category, separate them with commas.
Suleman
Date:: Jul 23, 2010
Time:: 07:04
Hi kavyagannarapu, As always with C# programming the first step in creating an application is to state which libraries arerequited and then to create a new class which extends the basic C# Windows form class: using System; using System.Windows.Forms; using System.Drawing; public class MainForm : Form { The next thing to do is to define the components required in the form. In this case a panel and three radio will be required: private Panel langPanel = new Panel(); private RadioButton radBritish = new RadioButton(); private RadioButton radFrench = new RadioButton(); private RadioButton radSpanish = new RadioButton(); The panel is required in order to group the radio buttons together. Radio buttons with the same parent (in this case the panel) always act as a single unit so that as one button is clicked all others in the group are unchecked automatically. Radio buttons with different parents (for example in more that one panel) will not interact with each other. The programmer can then define their new class’s main and constructor functions: public static void Main() { Application.Run(new MainForm()); } public MainForm() { setUpRadioButtons (); } The class’s constructor function calls another function (setUpRadioButtons) and it’s this one that sets up the radio buttons and the other components that are to be used on the form. Setting Up Radio Buttons with C# At this point the components have been created but are not yet connected to the new form. The programmer must: • State where the component is to be placed on the form • Add the component to the form The programm uses the “Location” property to define where the component should lie. In this example the panel has been placed in the top left of the form: public void setUpRadioButtons () { langPanel.Location = new Point(0,0); The location has two coordinates in “x” and “y”. Increasing “x” will move a component to the right, andincreasing “y” will move it down the form. Another useful property is “AutoSize”. Setting “AutoSize” to true will mean that the height and width of a component will automatically vary according do its contents: langPanel.AutoSize = true; Radio buttons share many of the same properties as panels (such as “Location” and “AutoSize”): radBritish.Location = new Point(0,0); radBritish.AutoSize = true; However, there are some additional properties for the programmer to use. The “Text” is used to place an appropriate message next to the radio button, and setting “Checked” to true for a radio button will make it the default one: radBritish.Text = "English"; radBritish.Checked = true; Each of the radio buttons is set in the same way (but only one should have “Checked” set to true): radFrench.Location = new Point(radBritish.Width,0); radFrench.AutoSize = true; radFrench.Text = "French"; radSpanish.Location = new Point (radBritish.Width + radFrench.Width,0); radSpanish.AutoSize = true; radSpanish.Text = "Spanish"; lblDay.Location = new Point(0,radBritish.Height); lblDay.AutoSize = true; And finally the programmer must add the components to the form: langPanel.Controls.Add(radBritish); langPanel.Controls.Add(radFrench); langPanel.Controls.Add(radSpanish); this.Controls.Add(langPanel); } If the form is compiled at this point then the application you will see three simple but effective radio buttons.
Date:: Aug 09, 2010
Time:: 05:24
Hi kavyagannarapu, Did my previous post help you at all ?
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
Hi is there a way to retrieve the loop count in XSLT
how do repair this problem: every times i opened my laptop it will suddenly n...
How i get the hp pavilion dv6-3054tx laptop bottom base assembly as a sparepa...
I don't have AOL browser but privacy scan shows hundreds of files/cookies fro...
wireless keyboard has stopped working
need validation controller for textbox in java
You have 100 characters to use
Rank
Expert
Points
1.
10279
2.
6493
3.
5596
4.
4848
5.
3487
6.
2840
7.
2770
8.
2303
9.
1820
10.
917
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software