.net - C++ Transferring Variable between Buttons -
in code want re-use buttons, since dont want deal tons of them... variables use change events of buttons not transferring... how make variable global enough if changed 1 button, x = 1, can used button, x = 1 in button well? here code 2 buttons... int ^ yesorno has been initialized outside of 2 buttons, making them accessible not change-able buttons...
private: system::void button2_click(system::object^ sender, system::eventargs^ e) { -> button4 -> visible = true; -> button2 -> visible = false; -> button5 -> visible = true; -> button3 -> visible = false; -> label2 -> visible = true; -> label2 -> text = "are sure?"; yesorno = 1; } private: system::void button4_click(system::object^ sender, system::eventargs^ e) { if (yesorno == 1) { -> label2 -> text = "to make pony character, see ponymakin.txt in your... etc; button4 -> text = "show pony"; yesorno = 2; } else if (yesorno == 2) { -> picturebox3 -> load("ponycharacter.jpg"); } }
i have declared int ^ yesorno; outside 2 buttons, both have access it, when 1 button changes yesorno 1, other button still see if initialized! know because both buttons void, don't know how change either...
replace int^ int . work . , see ^ meaning link what caret (‘^’) mean in c++/cli?
Comments
Post a Comment