event handling for button click in visual c++
I want to retrive the data from a开发者_如何学Go textfield on the click of a button.
Add a new project of type "Visual C++/CLR/Windows Forms Application" to your solution.
Add a button and textbox to the designer.
Double-click the button on the designer. This should take you to the form code, where an event handler will have been created and registered for you.
In the body of that event handler, you may access the text field using its name from the design (the name is viewed/modified by right-clicking the item in the form designer and selecting "Properties").
Edit: I typically don't use C++ for Windows Forms applications, but this example seems to work:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::String^ txt = this->textBox1->Text;
txt += " augmented";
this->textBox1->Text = txt;
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
label1 -> Text= "Hello Yashan";
}
this is ok
精彩评论