To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > General > Code It Better

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Jun 7th, 2006, 06:07 AM   #1
Greyskull
Hyperactive Member
 
Greyskull's Avatar
 
Join Date: Dec 03
Location: somewhere in England
Posts: 292
Greyskull  is on a distinguished road (40+)
Question C# Win App - Radiobutton if statements

Code:
        //button to display branch name
        private void btnBranch_Click(object sender, EventArgs e)
        {
            //if no branch is selected
            if (rbtnKnight.Checked == false && rbtnWbldon.Checked == false && rbtnKston.Checked == false)
            {
                //show error message
                MessageBox.Show("Please select Branch!", "Error!");
            }

            else
            {
                //if user selects knightsbridge branch
                if (rbtnKnight.Checked == true)
                {
                    txtBranch.Text = "Knightsbridge";
                    btnCost.Focus();        //sets focus in the Cost button when msg is displayed
                }

                //if user selects Wimbledon branch  
                if (rbtnWbldon.Checked == true)
                {
                    txtBranch.Text = "Wimbledon";
                    //set focus on btnCost once branch name is displayed
                    btnCost.Focus();
                }

                //if user selects Kingston branch
                if (rbtnKston.Checked == true)
                {
                    txtBranch.Text = "Kingston";
                    //set focus on btnCost once Kingston branch is displayed
                    btnCost.Focus();
                }
            }

        }
The radiobuttons are placed in a group box (grpBranch)

Is there a way to make this better i.e making it to a switch statement?

Thanx in advance
Greyskull is offline   Reply With Quote
Old Feb 3rd, 2009, 07:05 PM   #2
Pac_741
Hyperactive Member
 
Pac_741's Avatar
 
Join Date: Jun 07
Location: Mexico
Posts: 267
Pac_741 is an unknown quantity at this point (<10)
Thumbs up Re: C# Win App - Radiobutton if statements

Hello, maybe you can create an integer and set a value when the radio buttons are checked, and switch for that integer, good luck!
__________________

C# and WPF developer
My Website:
http://prox.exofire.net/
My Blog : http://prox.exofire.net/blog

Contact me
Pac_741 is offline   Reply With Quote
Reply

Go Back   VBForums > General > Code It Better


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:55 AM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.