如何在KeyEventArgs中同时处理两个函数.VC++2010.

How to handle two functions together in KeyEventArgs...VC++2010?

本文关键字:两个 VC++2010 函数 处理 KeyEventArgs      更新时间:2023-10-16

下面将详细介绍

我有一堂课

//MyDataHeaders.h
public ref class MyGlobalData {
//blah...blah...blah...
public: static System::Void Pty_NameCell( System::Object^ Sender, System::Windows::Forms::KeyEventArgs^ e) {
//blah..blah...
}
}; 

在 Form2 中,我有一个子...像下面一样..

//Form2.h
public: static System::Void MySupplier_LstVew() {
//blah..blah..
}
Form2_load() {
textBox2->KeyDown += gcnew KeyEventHandler(MyGlobalData::Pty_NameCell); //OK
};

但在这里我想使用

textBox2->KeyDown +=delegate { gcnew KeyEventHandler(MyGlobalData::Pty_NameCell); MySupplier_LstVew(); };

如何声明textBox2-> Keydwon事件与(MyGlobalData::Pty_NameCell),MySupplier_LstVew()在一起?可能吗?

谢谢

是的,你可以

textBox2->KeyDown += gcnew KeyEventHandler(MyGlobalData::Pty_NameCell);
textBox2->KeyDown += gcnew KeyEventHandler(MySupplier_LstVew);