RadioButton.Checked : RadioButton « System.Windows.Forms « C# / C Sharp by API

Home
C# / C Sharp by API
1.Microsoft.Win32
2.System
3.System.Collections
4.System.Collections.Generic
5.System.Collections.Specialized
6.System.ComponentModel
7.System.Configuration
8.System.Data
9.System.Data.Common
10.System.Data.Linq
11.System.Data.Odbc
12.System.Data.OleDb
13.System.Data.Sql
14.System.Data.SqlClient
15.System.Diagnostics
16.System.DirectoryServices
17.System.Drawing
18.System.Drawing.Drawing2D
19.System.Drawing.Imaging
20.System.Drawing.Printing
21.System.Drawing.Text
22.System.EnterpriseServices
23.System.Globalization
24.System.IO
25.System.IO.Compression
26.System.IO.IsolatedStorage
27.System.IO.Ports
28.System.Linq
29.System.Management
30.System.Media
31.System.Messaging
32.System.Net
33.System.Net.Mail
34.System.Net.NetworkInformation
35.System.Net.Sockets
36.System.Reflection
37.System.Resources
38.System.Runtime
39.System.Runtime.CompilerServices
40.System.Runtime.InteropServices
41.System.Runtime.Remoting
42.System.Runtime.Remoting.Channels
43.System.Runtime.Remoting.Channels.Http
44.System.Runtime.Remoting.Messaging
45.System.Runtime.Serialization
46.System.Runtime.Serialization.Formatters.Binary
47.System.Runtime.Serialization.Formatters.Soap
48.System.Security
49.System.Security.AccessControl
50.System.Security.Cryptography
51.System.Security.Cryptography.X509Certificates
52.System.Security.Permissions
53.System.Security.Policy
54.System.Security.Principal
55.System.ServiceProcess
56.System.Text
57.System.Text.RegularExpressions
58.System.Threading
59.System.Timers
60.System.Web.Security
61.System.Web.Services
62.System.Windows.Controls
63.System.Windows.Forms
64.System.Xml
65.System.Xml.Linq
66.System.Xml.Schema
67.System.Xml.Serialization
68.System.Xml.XPath
69.System.Xml.Xsl
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp by API » System.Windows.Forms » RadioButton 
RadioButton.Checked
  
  using System;
  using System.Drawing;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class CarConfigForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.ToolTip calendarTip;
    private System.Windows.Forms.Label label5;
    protected System.Windows.Forms.MonthCalendar monthCalendar;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label1;
    protected System.Windows.Forms.ComboBox comboSalesPerson;
    protected System.Windows.Forms.ListBox carMakeList;
    protected System.Windows.Forms.CheckedListBox checkedBoxRadioOptions;
    protected System.Windows.Forms.Button btnOrder;
    protected System.Windows.Forms.CheckBox checkFloorMats;
    protected System.Windows.Forms.RadioButton radioPink;
    protected System.Windows.Forms.RadioButton radioYellow;
    protected System.Windows.Forms.RadioButton radioRed;
    protected System.Windows.Forms.RadioButton radioGreen;
    protected System.Windows.Forms.GroupBox groupBox1;

    public CarConfigForm()
    {
      InitializeComponent();
      CenterToScreen();
    }

    private void InitializeComponent()
    {
      this.comboSalesPerson = new System.Windows.Forms.ComboBox ();
      this.radioRed = new System.Windows.Forms.RadioButton ();
      this.groupBox1 = new System.Windows.Forms.GroupBox ();
      this.radioPink = new System.Windows.Forms.RadioButton ();
      this.monthCalendar = new System.Windows.Forms.MonthCalendar ();
      this.checkedBoxRadioOptions = new System.Windows.Forms.CheckedListBox ();
      this.calendarTip = new System.Windows.Forms.ToolTip (new System.ComponentModel.Container());
      this.radioYellow = new System.Windows.Forms.RadioButton ();
      this.label5 = new System.Windows.Forms.Label ();
      this.carMakeList = new System.Windows.Forms.ListBox ();
      this.radioGreen = new System.Windows.Forms.RadioButton ();
      this.checkFloorMats = new System.Windows.Forms.CheckBox ();
      this.label3 = new System.Windows.Forms.Label ();
      this.btnOrder = new System.Windows.Forms.Button ();
      this.label1 = new System.Windows.Forms.Label ();
      this.label2 = new System.Windows.Forms.Label ();
      comboSalesPerson.Location = new System.Drawing.Point (1680);
      comboSalesPerson.Size = new System.Drawing.Size (12821);
      comboSalesPerson.TabIndex = 1;
      comboSalesPerson.Items.AddRange(new object[4] {"A""B""C""D"});
      radioRed.Location = new System.Drawing.Point (26424);
      radioRed.Text = "Red";
      radioRed.Size = new System.Drawing.Size (6423);
      radioRed.TabIndex = 2;
      radioRed.TabStop = true;
      radioRed.BackColor = System.Drawing.SystemColors.ControlLight;
      groupBox1.Location = new System.Drawing.Point (8120);
      groupBox1.TabIndex = 4;
      groupBox1.TabStop = false;
      groupBox1.Text = "Exterior Color";
      groupBox1.Size = new System.Drawing.Size (43256);
      groupBox1.Leave += new System.EventHandler (this.groupBox1_Leave);
      groupBox1.Enter += new System.EventHandler (this.groupBox1_Enter);
      radioPink.Location = new System.Drawing.Point (17624);
      radioPink.Text = "Pink";
      radioPink.Size = new System.Drawing.Size (5623);
      radioPink.TabIndex = 3;
      radioPink.TabStop = true;
      radioPink.BackColor = System.Drawing.SystemColors.ControlLight;

      monthCalendar.Location = new System.Drawing.Point (20224);
      calendarTip.SetToolTip (monthCalendar, "Please select the date (or dates)");
      monthCalendar.TabIndex = 10;
      monthCalendar.TabStop = true;
      checkedBoxRadioOptions.Location = new System.Drawing.Point (16832);
      checkedBoxRadioOptions.Cursor = Cursors.Hand;
      checkedBoxRadioOptions.Size = new System.Drawing.Size (15264);
      checkedBoxRadioOptions.CheckOnClick = true;
      checkedBoxRadioOptions.TabIndex = 2;
      checkedBoxRadioOptions.Items.AddRange(new object[6] {"1""2""3""4""5""6"});
      calendarTip.Active = true;
      radioYellow.Location = new System.Drawing.Point (9624);
      radioYellow.Text = "Yellow";
      radioYellow.Size = new System.Drawing.Size (5623);
      radioYellow.TabIndex = 1;
      radioYellow.TabStop = true;
      radioYellow.BackColor = System.Drawing.SystemColors.ControlLight;
      label5.Location = new System.Drawing.Point (20200);
      label5.Text = "Delivery Date:";
      label5.Size = new System.Drawing.Size (18416);
      label5.Font = new System.Drawing.Font ("Microsoft Sans Serif"9, System.Drawing.FontStyle.Bold);
      label5.TabIndex = 12;
      carMakeList.Location = new System.Drawing.Point (32832);
      carMakeList.Size = new System.Drawing.Size (11256);
      carMakeList.ScrollAlwaysVisible = true;
      carMakeList.TabIndex = 3;
      carMakeList.Sorted = true;
      carMakeList.Items.AddRange(new object[9] {"A""B""C""D""E""F""G""H""I"});
      radioGreen.Location = new System.Drawing.Point (1624);
      radioGreen.Text = "Green";
      radioGreen.Size = new System.Drawing.Size (6423);
      radioGreen.TabIndex = 0;
      radioGreen.TabStop = true;
      radioGreen.BackColor = System.Drawing.SystemColors.ControlLight;

      checkFloorMats.Location = new System.Drawing.Point (1616);
      checkFloorMats.Text = "Extra Floor Mats";
      checkFloorMats.Size = new System.Drawing.Size (11224);
      checkFloorMats.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
      checkFloorMats.TabIndex = 0;
      label3.Location = new System.Drawing.Point (3288);
      label3.Text = "Make:";
      label3.Size = new System.Drawing.Size (11216);
      label3.Font = new System.Drawing.Font ("Microsoft Sans Serif"9, System.Drawing.FontStyle.Bold);
      label3.TabIndex = 9;
      btnOrder.Location = new System.Drawing.Point (8440);
      btnOrder.Size = new System.Drawing.Size (12032);
      btnOrder.TabIndex = 6;
      btnOrder.Text = "Confirm Order";
      btnOrder.Click += new System.EventHandler (this.btnOrder_Click);
      label1.Location = new System.Drawing.Point (1656);
      label1.Text = "Sales Person";
      label1.Size = new System.Drawing.Size (14424);
      label1.TabIndex = 7;
      label2.Location = new System.Drawing.Point (1768);
      label2.Text = "Radio Options:";
      label2.Size = new System.Drawing.Size (14416);
      label2.Font = new System.Drawing.Font ("Microsoft Sans Serif"9, System.Drawing.FontStyle.Bold);
      label2.TabIndex = 8;
      this.Text = "Car Configurator";
      this.AutoScaleBaseSize = new System.Drawing.Size (513);
      this.ClientSize = new System.Drawing.Size (456485);
      groupBox1.Controls.Add (this.radioPink);
      groupBox1.Controls.Add (this.radioYellow);
      groupBox1.Controls.Add (this.radioRed);
      groupBox1.Controls.Add (this.radioGreen);
      this.Controls.Add (this.label5);
      this.Controls.Add (this.monthCalendar);
      this.Controls.Add (this.label3);
      this.Controls.Add (this.label2);
      this.Controls.Add (this.label1);
      this.Controls.Add (this.comboSalesPerson);
      this.Controls.Add (this.carMakeList);
      this.Controls.Add (this.checkedBoxRadioOptions);
      this.Controls.Add (this.btnOrder);
      this.Controls.Add (this.checkFloorMats);
      this.Controls.Add (this.groupBox1);
    }
    static void Main() 
    {
      Application.Run(new CarConfigForm());
    }

    protected void btnOrder_Click (object sender, System.EventArgs e)
    {
      if(comboSalesPerson.Text != "")
        Console.WriteLine("Sales Person: " + comboSalesPerson.Text);
      else
        Console.WriteLine("You did not select a sales person!");

      if(carMakeList.SelectedItem != null)
        Console.WriteLine("Make: " + carMakeList.SelectedItem);

      if(checkFloorMats.Checked)
        Console.WriteLine("You want floor mats.");  

      if(radioRed.Checked)
        Console.WriteLine("You want a red exterior.");
      
      if(radioYellow.Checked)
        Console.WriteLine("You want a yellow exterior.");
      
      if(radioGreen.Checked)
        Console.WriteLine("You want a green exterior.");

      if(radioPink.Checked)
        Console.WriteLine("Why do you want a PINK exterior?");
      
      for(int i = 0; i < checkedBoxRadioOptions.Items.Count; i++)
      {
        if(checkedBoxRadioOptions.GetItemChecked(i))
        {
          Console.WriteLine("Radio Item: "+ checkedBoxRadioOptions.Items[i]);
        }                
      }

      DateTime startD = monthCalendar.SelectionStart;
      DateTime endD = monthCalendar.SelectionEnd;

      string dateStartStr = startD.Date.ToShortDateString();
      string dateEndStr = endD.Date.ToShortDateString();
      
      if(dateStartStr != dateEndStr)
      {
        Console.WriteLine("Date between" + dateStartStr + " and" + dateEndStr);      
      else{
        Console.WriteLine("You chose a single date:" + dateStartStr);
            }
    }

    protected void groupBox1_Leave (object sender, System.EventArgs e)
    {
      groupBox1.Text = "Exterior Color: Thanks for visiting the group...";
    }

    protected void groupBox1_Enter (object sender, System.EventArgs e)
    {
      groupBox1.Text = "Exterior Color: You are in the group...";
    }
  }

   
    
  
Related examples in the same category
1.RadioButton.Appearance
2.RadioButton.CheckedChanged
3.RadioButton.Image
4.RadioButton.ImageAlign
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.