Reputation: 41
I want to retrive the data from a textfield on the click of a button.
Upvotes: 1
Views: 14264
Reputation: 39
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
label1 -> Text= "Hello Yashan";
}
this is ok
Upvotes: -1
Reputation: 7365
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;
}
Upvotes: 2