I create a user control group sub-class. There are two radiobuttons. I need to create event handlers for them. I have two directions to go. One is to create event handlers in the sub class and let the event handler to change a constant in the subclass. I will use a function to check the sub class constant in the upper class. The other one is to create event handlers in the upper class for the sub-class radio buttons. The following is my code for method 1.Note I have commented out two lines (they are the event handler creation) because they are wrong because they create errors please help
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Collections;
using namespace System::Collections::Generic;
#include <stdio.h>
#include <stdlib.h>
#using <mscorlib.dll>
public ref class temp_groupbox: public GroupBox
{
public: temp_groupbox(int a, int b, String ^groupboxname){
// Create and initialize a GroupBox and two RadioButton controls.
//GroupBox^ groupBox1 = gcnew GroupBox;
RadioButton^ radioButton1 = gcnew RadioButton;
RadioButton^ radioButton2 = gcnew RadioButton;
// Add the RadioButtons to the GroupBox.
this->Controls->Add( radioButton1 );
this->Controls->Add( radioButton2 );
this->Location = System::Drawing::Point(a, b);
this->Size = System::Drawing::Size(500, 100);
this->TabIndex = 0;
this->TabStop = false;
radioButton1->Name = L"radioButton1";
radioButton2->Name = L"radioButton2";
radioButton1->Size = System::Drawing::Size(85, 17);
radioButton2->Size = System::Drawing::Size(85, 17);
radioButton1->Location = System::Drawing::Point(30, 40);
radioButton2->Location = System::Drawing::Point(30, 90);
radioButton1->TabIndex = 0;
radioButton1->TabStop = true;
radioButton2->TabIndex = 1;
radioButton2->TabStop = true;
radioButton1->UseVisualStyleBackColor = true;
radioButton1->CheckedChanged += gcnew System::EventHandler(this, radioButton1_CheckedChanged);
radioButton2->UseVisualStyleBackColor = true;
radioButton2->CheckedChanged += gcnew System::EventHandler(this, radioButton2_CheckedChanged);
this->SuspendLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
public: RadioButton^ radioButton1;
public: RadioButton^ radioButton2;
public: int anss;
void radioButton1_CheckedChanged(Object^ sender, EventArgs^ e)
{
anss = 1;
}
void radioButton2_CheckedChanged(Object^ sender, EventArgs^ e)
{
anss = 2;
}
};// end ref class

Do you have methods
radioButton1_CheckedChangedandradioButton2_CheckedChangeddefined?If these methods already exist, please list the error message you’re getting. It’s hard to figure out how to fix something if we don’t know what’s wrong.
You need to specify the full class name of the method you’re creating a delegate for, and use the
&to take the address of it.