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

📄 radiobuttonstest.cs

📁 this is a good book for the visual c#
💻 CS
📖 第 1 页 / 共 2 页
字号:
         this.iconTypeGroupBox.Size = 
            new System.Drawing.Size( 136, 176 );
         this.iconTypeGroupBox.TabIndex = 1;
         this.iconTypeGroupBox.TabStop = false;
         this.iconTypeGroupBox.Text = "Icon";

         // 
         // questionButton
         // 
         this.questionButton.Location = 
            new System.Drawing.Point( 16, 144 );
         this.questionButton.Name = "questionButton";
         this.questionButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.questionButton.TabIndex = 0;
         this.questionButton.Text = "Question";

         // all radio buttons for icon types are registered
         // to iconType_CheckedChanged event handler
         this.questionButton.CheckedChanged += 
            new System.EventHandler(
            this.iconType_CheckedChanged );

         // 
         // exclamationButton
         // 
         this.exclamationButton.Location = 
            new System.Drawing.Point( 16, 64 );
         this.exclamationButton.Name = "exclamationButton";
         this.exclamationButton.Size = 
            new System.Drawing.Size( 104, 23 );
         this.exclamationButton.TabIndex = 2;
         this.exclamationButton.Text = "Exclamation";
         this.exclamationButton.CheckedChanged += 
            new System.EventHandler(
            this.iconType_CheckedChanged );

         // 
         // errorButton
         // 
         this.errorButton.Location = 
            new System.Drawing.Point( 16, 24 );
         this.errorButton.Name = "errorButton";
         this.errorButton.Size = 
            new System.Drawing.Size( 100, 23 );
         this.errorButton.TabIndex = 1;
         this.errorButton.Text = "Error";
         this.errorButton.CheckedChanged += 
            new System.EventHandler(
            this.iconType_CheckedChanged );

         // 
         // displayLabel
         // 
         this.displayLabel.Location = 
            new System.Drawing.Point( 200, 304 );
         this.displayLabel.Name = "displayLabel";
         this.displayLabel.Size = 
            new System.Drawing.Size( 136, 24 );
         this.displayLabel.TabIndex = 4;

         // 
         // displayButton
         // 
         this.displayButton.Location = 
            new System.Drawing.Point( 200, 240 );
         this.displayButton.Name = "displayButton";
         this.displayButton.Size = 
            new System.Drawing.Size( 136, 48 );
         this.displayButton.TabIndex = 3;
         this.displayButton.Text = "Display";
         this.displayButton.Click += 
            new System.EventHandler( this.displayButton_Click );

         // 
         // promptLabel
         // 
         this.promptLabel.Font = 
            new System.Drawing.Font(
            "Microsoft Sans Serif", 9.5F, 
            System.Drawing.FontStyle.Regular, 
            System.Drawing.GraphicsUnit.Point, 
            ( ( System.Byte )( 0 ) ) );
         this.promptLabel.Location = 
            new System.Drawing.Point( 8, 16 );
         this.promptLabel.Name = "promptLabel";
         this.promptLabel.Size = 
            new System.Drawing.Size( 344, 24 );
         this.promptLabel.TabIndex = 5;
         this.promptLabel.Text = "Choose the type of " +
            "MessageBox you would like to display!";

         // 
         // RadioButtonsTest
         // 
         this.AutoScaleBaseSize = 
            new System.Drawing.Size( 5, 13 );
         this.ClientSize = 
            new System.Drawing.Size( 360, 341 );
         this.Controls.AddRange(
            new System.Windows.Forms.Control[] {
               this.promptLabel,
               this.displayLabel,
               this.displayButton,
               this.iconTypeGroupBox,
               this.buttonTypeGroupBox } );
         this.Name = "RadioButtonsTest";
         this.Text = "Demonstrating RadioButtons";
         this.buttonTypeGroupBox.ResumeLayout( false );
         this.iconTypeGroupBox.ResumeLayout( false );
         this.ResumeLayout( false );

      } // end method InitializeComponent

		#endregion

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main() 
      {
         Application.Run( new RadioButtonsTest() );
      }

      // change button based on option chosen by sender
      private void buttonType_CheckedChanged(
         object sender, System.EventArgs e )
      {
         if ( sender == okButton ) // display OK button
            buttonType = MessageBoxButtons.OK;

         // display OK and Cancel buttons
         else if ( sender == okCancelButton )
            buttonType = MessageBoxButtons.OKCancel;

         // display Abort, Retry and Ignore buttons
         else if ( sender == abortRetryIgnoreButton )
            buttonType = MessageBoxButtons.AbortRetryIgnore;

         // display Yes, No and Cancel buttons
         else if ( sender == yesNoCancelButton )
            buttonType = MessageBoxButtons.YesNoCancel;

         // display Yes and No buttons
         else if ( sender == yesNoButton )
            buttonType = MessageBoxButtons.YesNo;

         // only one option left--display 
         // Retry and Cancel buttons
         else
            buttonType = MessageBoxButtons.RetryCancel;

      } // end method buttonType_CheckedChanged

      // change icon based on option chosen by sender
      private void iconType_CheckedChanged(
         object sender, System.EventArgs e )
      {
         if ( sender == errorButton ) // display error icon
            iconType = MessageBoxIcon.Error;

         // display exclamation point
         else if ( sender == exclamationButton )
            iconType = MessageBoxIcon.Exclamation;

         // display information icon
         else if ( sender == informationButton ) 
            iconType = MessageBoxIcon.Information;

         else // only one option left--display question mark
            iconType = MessageBoxIcon.Question;

      } // end method iconType_CheckedChanged

      // display MessageBox and button user pressed
      protected void displayButton_Click( 
         object sender, System.EventArgs e )
      {
         DialogResult result = 
            MessageBox.Show( "This is Your Custom MessageBox.", 
            "Custom MessageBox", buttonType, iconType, 0, 0 );

         // check for dialog result and display it in label
         switch ( result )
         {
            case DialogResult.OK: 
               displayLabel.Text = "OK was pressed."; 
               break;

            case DialogResult.Cancel: 
               displayLabel.Text = "Cancel was pressed."; 
               break;

            case DialogResult.Abort: 
               displayLabel.Text = "Abort was pressed."; 
               break;

            case DialogResult.Retry: 
               displayLabel.Text = "Retry was pressed."; 
               break;

            case DialogResult.Ignore: 
               displayLabel.Text = "Ignore was pressed."; 
               break;

            case DialogResult.Yes: 
               displayLabel.Text = "Yes was pressed."; 
               break;

            case DialogResult.No: 
               displayLabel.Text = "No was pressed."; 
               break;

         } // end switch

      } // end method displayButton_Click

   } // end class RadioButtonsTest

} // end namespace RadioButtonsTest

/*
 **************************************************************************
 * (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall.     *
 * All Rights Reserved.                                                   *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 **************************************************************************
*/

⌨️ 快捷键说明

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