访问表单加载事件中的对象?

时间:2016-01-24 18:20:23

标签: winforms c++-cli

我在Windows窗体c ++ / CLI应用程序中制作节拍。

如何访问$(document).ready(function () { var num; var arbt=["yellow","green","blue","magenta","red","white","lime"]; $("a").each(function (index) { var ran = Math.floor((Math.random() * arbt.length) + 1); var colo = arbt[ran]; $(this).css('background-color', colo); }) }) 事件中的对象?

Form1_Load

产生的错误是public: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { System::Windows::Media::MediaPlayer^ cymbal = gcnew System::Windows::Media::MediaPlayer(); cymbal->Open(gcnew System::Uri("wav file directory")); } private: System::Void button1_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) { if(e->KeyCode == Keys::R) cymbal->Play(); } 是未声明的标识符。

1 个答案:

答案 0 :(得分:0)

您需要向句柄添加范围。如果您的班级名称是MyClass 那么这应该是句柄的签名:

System::Void MyClass::button1_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e)