Kujon
11.12.12,16:01
Dobrý deň začínam pracovať vo Visual Studiu 2012 v C++ takmer všetky základy už ovládam tak som chcel prejsť na vyššiu kategóriu.

Chcel by som pomocou stringu a TextBoxu alebo labelu niečo vypisovať na obrazovku a tu nastal môj problem:

časť kódu:

toto mi funguje lebo mam viac variantov vypisovať na obrazovku:

long int TDDusername = 50;
char lol [1];
lol[0]
'p';
this->textBox1->Text
lol[0].ToString();

toto mi tiež funguje:

this->textBox1->Text = "a";
this->textBox1->Text += " ";
this->textBox1->Text += "a";
textBox1->Text = "+";

a toto mi nefunguje:

string lool = ("lool");
this->textBox1->Text = lool;
Kujon
11.12.12,15:01
Tu je celi kod... to v buttone v komentare je chyba

#include
#pragma once


namespace WindowsFormsApplication4 {


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


///
/// Summary for Form1
///

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}


protected:
///
/// Clean up any resources being used.
///

~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ textBox1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;


private:
///
/// Required designer variable.
///

System::ComponentModel::Container ^components;


#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(12, 12);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(156, 20);
this->textBox1->TabIndex = 0;
//
// button1
//
this->button1->Location = System::Drawing::Point(12, 38);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"zmena 1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(12, 67);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 2;
this->button2->Text = L"zmena 2";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(12, 96);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 23);
this->button3->TabIndex = 3;
this->button3->Text = L"zmena 3";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(93, 38);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(75, 23);
this->button4->TabIndex = 4;
this->button4->Text = L"clear";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(195, 135);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();


}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
long int TDDusername = 50;
char lol [1];
lol[0]= 'p';
this->textBox1->Text = lol[0].ToString();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text = "a";
this->textBox1->Text += " ";
this->textBox1->Text += "a";
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
string lool = ("lool");
//this->textBox1->Text = lool;
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text = "";
}
};
}