winforms - Accessing objects in a Form Load Event? -


im making beat pad in windows forms c++/cli application.

how access objects in form1_load event?

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();     } 

the error produced cymbal undeclared identifier.

you need add scope handle. if class name myclass should handle's signature:

system::void myclass::button1_keydown(system::object^  sender, system::windows::forms::keyeventargs^  e) 

Comments