将keyup事件添加到c ++文本框

时间:2014-02-09 18:31:29

标签: c++ visual-studio events

我正在尝试将事件处理程序添加到我在C ++中的文本框中,并且收到以下错误:

  

错误1错误C2664:'void System :: Windows :: Forms :: Control :: KeyPress :: add(System :: Windows :: Forms :: KeyPressEventHandler ^)':无法从'System ::转换参数1 EventHandler ^'到'System :: Windows :: Forms :: KeyPressEventHandler ^'

以下是我正在处理的代码:

this->textBox2->Location = System::Drawing::Point(173, 31);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(172, 20);
this->textBox2->TabIndex = 5;
this->textBox2->KeyPress += gcnew System::EventHandler(this, &MyForm::textBox2_keyUp);

这是事件函数:

private: void textBox2_keyUp(Object^ sender, System::EventArgs^ e)
{
  phrase = textBox2->Text;
  MyForm::HighlightedNotRadioButton_CheckedChanged(sender, e);
}

导致错误的原因是什么?

0 个答案:

没有答案