C# 在c语言中使用收音机盒时的混淆#

C# 在c语言中使用收音机盒时的混淆#,c#,winforms,C#,Winforms,我有一个c语言的代码,它使用可视化组件 我在一个群发盒里有一些收音机 如何对此groupeBox进行CheckedChanged事件 我通常通过点击按钮来制作事件,虽然我不能通过点击groupeBox来制作CheckChanged事件;它会生成一个单击事件或输入事件 我还添加了我的讲师代码 // Using RadioButtons to set message window options. using System; using System.Windows.Forms; namespac

我有一个c语言的代码,它使用可视化组件

我在一个群发盒里有一些收音机

如何对此groupeBox进行CheckedChanged事件

我通常通过点击按钮来制作事件,虽然我不能通过点击groupeBox来制作CheckChanged事件;它会生成一个单击事件或输入事件

我还添加了我的讲师代码

// Using RadioButtons to set message window options.
using System;
using System.Windows.Forms;

namespace RadioButtonTest
{
    // Form contains several RadioButtons--user chooses one
    // from each group to create a custom MessageBox
    public partial class RadioButtonTestForm : Form
    {
      // create variables that store the user's choice of options
      private MessageBoxIcon iconType;
      private MessageBoxButtons buttonType;

      // default constructor
      public RadioButtonTestForm()
      {
         InitializeComponent();
      } // end constructor

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

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

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

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

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

         // only on option left--display Retry and Cancel Buttons
         else
            buttonType = MessageBoxButtons.RetryCancel;
      } // end method buttonType_Changed

      // change Icon based on option chosen by sender
      private void iconType_CheckedChanged( object sender, EventArgs e )
      {
         if ( sender == asteriskRadioButton ) // display asterisk Icon
            iconType = MessageBoxIcon.Asterisk;

         // display error Icon
         else if ( sender == errorRadioButton )
            iconType = MessageBoxIcon.Error;

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

         // display hand Icon
         else if ( sender == handRadioButton )
            iconType = MessageBoxIcon.Hand;

         // display information Icon
         else if ( sender == informationRadioButton )
            iconType = MessageBoxIcon.Information;

         // display question mark Icon
         else if ( sender == questionRadioButton )
            iconType = MessageBoxIcon.Question;

         // display stop Icon
         else if ( sender == stopRadioButton )
            iconType = MessageBoxIcon.Stop;

         // only one option left--display warning Icon
         else
            iconType = MessageBoxIcon.Warning;
      } // end method iconType_CheckChanged

      // display MessageBox and Button user pressed
      private void displayButton_Click( object sender, EventArgs e )
      {
         // display MessageBox and store
         // the value of the Button that was pressed
         DialogResult result = MessageBox.Show(
            "This is your Custom MessageBox.", "Custom MessageBox",
            buttonType, iconType);

         // check to see which Button was pressed in the MessageBox
         // change text displayed accordingly
         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
      }

      private void RadioButtonTestForm_Load(object sender, EventArgs e)
      {

      }

      private void buttonTypeGroupBox_Enter(object sender, EventArgs e)
      {

      }

      private void iconTypeGroupBox_Enter(object sender, EventArgs e)
      {

      } // end method displayButton_Click
   } // end class RadioButtonsTestForm
} // end namespace RadioButtonsTest

CheckedChanged
事件在单选按钮上,而不是在分组框上。但您可以做的是将所有单选按钮指向同一个处理程序。如果转到“属性”窗口中的事件列表,则会出现一个小的闪电图标。单击该按钮,您将获得所有事件的列表,您可以在其中为所有事件选择相同的处理程序。

Basic 101 on
如何使用我的行业工具
。在单选按钮上单击鼠标右键。选择属性,选择事件窗口(属性窗口中的Lightning图标)搜索CheckedChanged事件并双击它……我的问题是,我认为添加到groupBox的所有组件都将是该groupBox的一部分。现在我想检查GroupBox的CheckedChanged,而不是单选按钮。你能说怎么做吗@MediaDepp没有适用于您的GroupBox的CheckedChanged EventHandler,正如其他人所说,它位于单选按钮上。当您将项目放置在容器中时,容器不会继承包含的项目的事件。然后您可能需要考虑将此标记为正确答案。