Visual Studio problem

Hello,

I understand this may be very simply for moSt, but I'm trying to create a window form that has a button that when I click it. It populates Hello World in the textbox.

All the YouTube video said just double click the button, and enter name of textbox->text="Hello World";

When I run it,there's no errors but the form does not pop up with the interactive button. Where am I going wrong

#pragma once

namespace ConsoleApplication1 {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for MyForm1
/// </summary>
public ref class MyForm1 : public System::Windows::Forms::Form
{
public:
MyForm1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ ButtonClick;
private: System::Windows::Forms::TextBox^ TextBoxMessage;
protected:

protected:


private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->ButtonClick = (gcnew System::Windows::Forms::Button());
this->TextBoxMessage = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// ButtonClick
//
this->ButtonClick->Location = System::Drawing::Point(84, 113);
this->ButtonClick->Name = L"ButtonClick";
this->ButtonClick->Size = System::Drawing::Size(75, 23);
this->ButtonClick->TabIndex = 0;
this->ButtonClick->Text = L"Click";
this->ButtonClick->UseVisualStyleBackColor = true;
this->ButtonClick->Click += gcnew System::EventHandler(this, &MyForm1::button1_Click);
//
// TextBoxMessage
//
this->TextBoxMessage->Location = System::Drawing::Point(84, 45);
this->TextBoxMessage->Name = L"TextBoxMessage";
this->TextBoxMessage->Size = System::Drawing::Size(100, 20);
this->TextBoxMessage->TabIndex = 1;
//
// MyForm1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 261);
this->Controls->Add(this->TextBoxMessage);
this->Controls->Add(this->ButtonClick);
this->Name = L"MyForm1";
this->Text = L"MyForm1";
this->Load += gcnew System::EventHandler(this, &MyForm1::MyForm1_Load);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void MyForm1_Load(System::Object^ sender, System::EventArgs^ e) {

}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

TextBoxMessage-> Text = "Hello World";
}
};
}
Last edited on
It works for me.

Can you show us your main function?
I don't understand what you mean. Wouldn't this be it.
The main function should be located in one of the .cpp files.
Topic archived. No new replies allowed.