- Create New Project using template of Visual C++ Windows Form Application, with Name of "HelloWorld", and click OK.

- Click on "Toolbox" on right to expand Toolbox, drag a label and button over the Form.

- Double Click on the button, to generate the code of button1_Click() method. Visual C++ will open the code designer for you.
- Add the code inside button1_Click() method:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
label1->Text = "Hello World";
}
};

- Save and Run.
Click on the button, the text on the label will be changed to "Hello World".

No comments:
Post a Comment