Radio Button

Determinging weather a radio button is checked

Page 1 of 1

4 Replies - 5054 Views - Last Post: 08 February 2010 - 12:39 AM Rate Topic: -----

#1 mattiboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-January 10

Radio Button

Posted 07 February 2010 - 06:23 PM

I am working on this exercise in my C# Programming class...

What I'm trying to do is to make a method

so that:

if a radio button is checked then the lable counter Part will have it's visibility change to true

as well as the Summary's visibility

Once the order is complete

It will become visible

However,

I tried writing it out and I got a whole list of errors instead


If someone could review my code and help me out it would be greatly appreciated

Thanks

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Radio Button

#2 pdkharkar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 345
  • Joined: 19-January 09

Re: Radio Button

Posted 07 February 2010 - 06:43 PM

I think you already have the solution
you have to just write some lines according to your problem
for example
you want to change label's visibility to true when radiobutton is checked.
Now you have to write the code in the button_checkchanged event such that label becomes true
here I will show one example
make changes in your code and if error comes then ask again
here is the example
 private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            label1.Visible = true;
        }


Was This Post Helpful? 1
  • +
  • -

#3 mattiboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-January 10

Re: Radio Button

Posted 07 February 2010 - 10:47 PM

View Postpdkharkar, on 07 February 2010 - 05:43 PM, said:

I think you already have the solution
you have to just write some lines according to your problem
for example
you want to change label's visibility to true when radiobutton is checked.
Now you have to write the code in the button_checkchanged event such that label becomes true
here I will show one example
make changes in your code and if error comes then ask again
here is the example
 private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            label1.Visible = true;
        }






Heya,

So I heard what you said...

I decided to rearrange things a little bit but I get the same Error CS0118 and a few other I am not sure what they are

I have a list below:



Error 1 A field initializer cannot reference the non-static field, method, or property 'CS_Mail.Form1.rbGround'


Error 2 'System.Windows.Forms.RadioButton' is a 'type' but is used like a 'variable' C:\Users\St3aLtHy\Documents


Error 3 'CS_Mail.Form1.rbCharge' is a 'field' but is used like a 'type' C:\Users\St3aLtHy\Documents\Visual Studio


Error 4 The name 'Charge' does not exist in the current context C:\Users\St3aLtHy\Documents\Visual Studio


Error 5 'CS_Mail.Form1.rbCOD' is a 'field' but is used like a 'type' C:\Users\St3aLtHy\Documents\Visual Studio


Error 6 'CS_Mail.Form1.rbMoneyOrder' is a 'field' but is used like a 'type' C:\Users\St3aLtHy\Documents\Visual

Error 7 'CS_Mail.Form1.rbExpress' is a 'field' but is used like a 'type' C:\Users\St3aLtHy\Documents\Visual


New Code Is attached:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CS_Mail
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        //Contact Constants

        const string CSHIPPING = "Shipping:\n \'Eric Andrews 500-4444\' ";

        const string CMARKETING = "Marketing:\n	\'Michelle Rigner 500-2222\' ";

        const string CORDPROC = "Order Processing:\n \'Kenna De Voss 500-3333\' ";

        const string CCUSTREL = "Customer Relations:\n \'Tricia Mills 500-1111\' ";

        //Radio Button Variables

        
        
        
        //Shipping Radio Buttons
        
        
        
        //Contact Info Buttons
        private void btnShipping_Click(object sender, EventArgs e)
        {
            lblShipping.Text = CSHIPPING.ToString();

        }

        private void btnMarketing_Click(object sender, EventArgs e)
        {
            lblMarketing.Text = CMARKETING.ToString();

        }

        private void btnOrdProc_Click(object sender, EventArgs e)
        {
            lblOrdProc.Text = CORDPROC.ToString();

        }

        private void btnCustRel_Click(object sender, EventArgs e)
        {
            lblCustRel.Text = CCUSTREL.ToString();

        }


        //Payment Type Summarry





        private void btnClear_Click(object sender, EventArgs e)
        {


        }

        //Accept & Clear Button's

        private void btnDisplayCatalog_Click(object sender, EventArgs e)
        {
            //Payment Type: If Rb is equal to Selected Display in The Summary
            //Payment Type

            RadioButton Charge = (rbCharge)sender;
        }

              private void rbCharge_CheckedChanged(object sender, EventArgs e)
        {

                     if (Charge.Checked)
                {
                    
                        lblSumChargePT.Visible = true;
                            }
                  {
        }}






                private void rbCOD_CheckedChanged(object sender, EventArgs e)
        {

         RadioButton COD = (rbCOD) sender;

                if (COD.Checked)
                {
                    lblSumCODPT.Visible = true;

                }

        }


            
            
                


        

        private void rbMoneyOrder_CheckedChanged(object sender, EventArgs e)
        {
        
        
               
              
                RadioButton MoneyOrder = (rbMoneyOrder) sender;

                if (MoneyOrder.Checked)
                {
                    lblSumMonOrd.Visible = true;
                }
        
    
        }
    
    
    
    
    //Shipping Type
               
        
        
        
        
        
        private void rbExpress_CheckedChanged(object sender, EventArgs e)
        {

        RadioButton Express =(rbExpress) sender;
        if (Express.Checked)
            
                {
                    lblSumExpressShip.Visible = true;
                }

                
            
            
        }
            
            RadioButton Ground = (rbGround == RadioButton);
            
             private void rbGround_CheckedChanged(object sender, EventArgs e)
        {
        
        
            
            if (Ground.Checked)
                {

                    lblSumGroundShip.Visible = true;
                }

            }
    

       

    }
            
            //gbSummary.Visible = true;
            //MessageBox.Show("Thank You,You're Order has been processed");


        }

       

       

      

        

        

        
       //When radio buttons are selected

        
        
    


    
    








Thankyou for the advice in advanced


Ignore the name of the txt file... its a very minor error it's relevant to the project though

Attached File(s)


This post has been edited by mattiboi: 07 February 2010 - 11:00 PM

Was This Post Helpful? 0
  • +
  • -

#4 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Radio Button

Posted 07 February 2010 - 10:49 PM

Please don't attach your code in a file. Post it in the topic with in code tags please. Thank you for helping us to help you better.
Was This Post Helpful? 0
  • +
  • -

#5 mattiboi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-January 10

Re: Radio Button

Posted 08 February 2010 - 12:39 AM

Problem Solved Thanks :)

This post has been edited by mattiboi: 08 February 2010 - 12:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1