⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radiobuttonstest.cs

📁 this is a good book for the visual c#
💻 CS
📖 第 1 页 / 共 2 页
字号:
// Fig. 12.26: RadioButtonsTest.cs
// Using RadioButtons to set message window options.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace RadioButtonsTest
{
   /// <summary>
   /// form contains several radio buttons--user chooses one
   /// from each group to create a custom MessageBox
   /// </summary>
   public class RadioButtonsTest : System.Windows.Forms.Form
   {
      private System.Windows.Forms.Label promptLabel;
      private System.Windows.Forms.Label displayLabel;
      private System.Windows.Forms.Button displayButton;

      private System.Windows.Forms.RadioButton questionButton;
      private System.Windows.Forms.RadioButton informationButton;
      private System.Windows.Forms.RadioButton exclamationButton;
      private System.Windows.Forms.RadioButton errorButton;
      private System.Windows.Forms.RadioButton retryCancelButton;
      private System.Windows.Forms.RadioButton yesNoButton;
      private System.Windows.Forms.RadioButton yesNoCancelButton;
      private System.Windows.Forms.RadioButton okCancelButton;
      private System.Windows.Forms.RadioButton okButton;
      private System.Windows.Forms.RadioButton
         abortRetryIgnoreButton;

      private System.Windows.Forms.GroupBox iconTypeGroupBox;
      private System.Windows.Forms.GroupBox buttonTypeGroupBox;

      private MessageBoxIcon iconType = MessageBoxIcon.Error;
      private MessageBoxButtons buttonType = 
         MessageBoxButtons.OK;
      
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;

      // default constructor
      public RadioButtonsTest()
      {
         InitializeComponent();
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      protected override void Dispose( bool disposing )
      {
         if ( disposing )
         {
            if ( components != null ) 
            {
               components.Dispose();
            }
         }

         base.Dispose( disposing );
      }

		#region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
         this.informationButton = 
            new System.Windows.Forms.RadioButton();
         this.buttonTypeGroupBox = 
            new System.Windows.Forms.GroupBox();
         this.retryCancelButton = 
            new System.Windows.Forms.RadioButton();
         this.yesNoButton = 
            new System.Windows.Forms.RadioButton();
         this.yesNoCancelButton = 
            new System.Windows.Forms.RadioButton();
         this.abortRetryIgnoreButton = 
            new System.Windows.Forms.RadioButton();
         this.okCancelButton = 
            new System.Windows.Forms.RadioButton();
         this.okButton = 
            new System.Windows.Forms.RadioButton();
         this.iconTypeGroupBox = new System.Windows.Forms.GroupBox();
         this.questionButton = 
            new System.Windows.Forms.RadioButton();
         this.exclamationButton = 
            new System.Windows.Forms.RadioButton();
         this.errorButton = 
            new System.Windows.Forms.RadioButton();
         this.displayLabel = new System.Windows.Forms.Label();
         this.displayButton = 
            new System.Windows.Forms.Button();
         this.promptLabel = new System.Windows.Forms.Label();
         this.buttonTypeGroupBox.SuspendLayout();
         this.iconTypeGroupBox.SuspendLayout();
         this.SuspendLayout();

         // 
         // informationButton
         // 
         this.informationButton.Location = 
            new System.Drawing.Point( 16, 104 );
         this.informationButton.Name = "informationButton";
         this.informationButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.informationButton.TabIndex = 4;
         this.informationButton.Text = "Information";
         this.informationButton.CheckedChanged += 
            new System.EventHandler(
            this.iconType_CheckedChanged );

         // 
         // buttonTypeGroupBox
         // 
         this.buttonTypeGroupBox.Controls.AddRange( 
            new System.Windows.Forms.Control[] {
               this.retryCancelButton,
               this.yesNoButton,
               this.yesNoCancelButton,
               this.abortRetryIgnoreButton,
               this.okCancelButton,
               this.okButton } );
         this.buttonTypeGroupBox.Location = 
            new System.Drawing.Point( 16, 56 );
         this.buttonTypeGroupBox.Name = "buttonTypeGroupBox";
         this.buttonTypeGroupBox.Size = 
            new System.Drawing.Size( 152, 272 );
         this.buttonTypeGroupBox.TabIndex = 0;
         this.buttonTypeGroupBox.TabStop = false;
         this.buttonTypeGroupBox.Text = "Button Type";

         // 
         // retryCancelButton
         // 
         this.retryCancelButton.Location = 
            new System.Drawing.Point( 16, 224 );
         this.retryCancelButton.Name = "retryCancelButton";
         this.retryCancelButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.retryCancelButton.TabIndex = 4;
         this.retryCancelButton.Text = "RetryCancel";

         // all radio buttons for button types are registered
         // to buttonType_CheckedChanged event handler
         this.retryCancelButton.CheckedChanged += 
            new System.EventHandler(
            this.buttonType_CheckedChanged );

         // 
         // yesNoButton
         // 
         this.yesNoButton.Location = new System.Drawing.Point( 16, 184 );
         this.yesNoButton.Name = "yesNoButton";
         this.yesNoButton.Size = new System.Drawing.Size( 100, 23 );
         this.yesNoButton.TabIndex = 0;
         this.yesNoButton.Text = "YesNo";
         this.yesNoButton.CheckedChanged += 
            new System.EventHandler(
            this.buttonType_CheckedChanged );

         // 
         // yesNoCancelButton
         // 
         this.yesNoCancelButton.Location = 
            new System.Drawing.Point( 16, 144 );
         this.yesNoCancelButton.Name = "yesNoCancelButton";
         this.yesNoCancelButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.yesNoCancelButton.TabIndex = 3;
         this.yesNoCancelButton.Text = "YesNoCancel";
         this.yesNoCancelButton.CheckedChanged += 
            new System.EventHandler(
            this.buttonType_CheckedChanged );

         // 
         // abortRetryIgnoreButton
         // 
         this.abortRetryIgnoreButton.Location = 
            new System.Drawing.Point( 16, 104 );
         this.abortRetryIgnoreButton.Name = 
            "abortRetryIgnoreButton";
         this.abortRetryIgnoreButton.Size = 
            new System.Drawing.Size( 120, 23 );
         this.abortRetryIgnoreButton.TabIndex = 2;
         this.abortRetryIgnoreButton.Text = "AbortRetryIgnore";
         this.abortRetryIgnoreButton.CheckedChanged += 
            new System.EventHandler(
            this.buttonType_CheckedChanged );

         // 
         // okCancelButton
         // 
         this.okCancelButton.Location = 
            new System.Drawing.Point( 16, 64 );
         this.okCancelButton.Name = "okCancelButton";
         this.okCancelButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.okCancelButton.TabIndex = 1;
         this.okCancelButton.Text = "OKCancel";
         this.okCancelButton.CheckedChanged += 
            new System.EventHandler(
            this.buttonType_CheckedChanged );

         // 
         // okButton
         // 
         this.okButton.Checked = true;
         this.okButton.Location = 
            new System.Drawing.Point( 16, 24 );
         this.okButton.Name = "okButton";
         this.okButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.okButton.TabIndex = 0;
         this.okButton.TabStop = true;
         this.okButton.Text = "OK";
         this.okButton.CheckedChanged += 
            new System.EventHandler(
            this.buttonType_CheckedChanged );

         // 
         // iconTypeGroupBox
         // 
         this.iconTypeGroupBox.Controls.AddRange(
            new System.Windows.Forms.Control[] {
               this.questionButton,
               this.informationButton,
               this.exclamationButton,
               this.errorButton } );
         this.iconTypeGroupBox.Location = 
            new System.Drawing.Point( 200, 56 );
         this.iconTypeGroupBox.Name = "iconTypeGroupBox";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -