1
我剛剛進入C++ CLI,並遇到一些問題,其中一些事件處理程序被調用,有些不是。C++ CLI事件處理程序沒有被觸發
這裏是我的事件處理程序的列表:
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
Application::Exit();
}
private: System::Void aboutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Paul Madsen\nLab 13",
"About lab 13", MessageBoxButtons::OK,
MessageBoxIcon::Asterisk);
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
try
{
double tmp = Double::Parse(textBox1->Text);
}
catch(...)
{
textBox1->ResetText();
}
}
private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
try
{
double tmp = Double::Parse(textBox2->Text);
}
catch(...)
{
textBox2->ResetText();
}
}
private: System::Void textBox1_Enter(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Test",
"test", MessageBoxButtons::OK,
MessageBoxIcon::Asterisk);
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
double tmp = (Double::Parse(textBox1->Text) - 32) * 5/9;
textBox2->Text = System::Convert::ToString(tmp);
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
double tmp = (Double::Parse(textBox1->Text) - 32) * 5/9;
textBox1->Text = System::Convert::ToString(tmp);
}
的button1_Click工作得很好,但button2_Click永遠不會觸發,即使它們在本質上是相同的。這是爲什麼?