×
Felmeddelande :( Din CSS har inte laddats som den ska. Testa reloada sidan.
1

VC++ 2010 Forms Application

Postat av failman den 22 November 2014, 11:37
3 kommentarer · 341 träffar
Hallå!

Behöver hjälp med lite programmering i Visual C++ 2010 express "Forms application".

Genom att trycka på knappen "Add", så ska den ta texten från txtitem och lägga till i txtlist och på så sätt skapa en lista. Väldigt basic kanske, men jag får inte till det.
Jag vet att knapparna och textrutorna inte stämmer, men måste ha hjälp klarar inte av att tänka mer :)!


Kod:

#pragma once

namespace matlistan {

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 Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ btnadd;
protected:
private: System::Windows::Forms::Label^ txtinfo;
private: System::Windows::Forms::Label^ txtlistan;
private: System::Windows::Forms::TextBox^ txtitem;
private: System::Windows::Forms::TextBox^ txtlist;
private: System::Windows::Forms::Button^ btnclear;
private: System::Windows::Forms::Button^ btnExit;



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

//Variables
private:
String ^ Matlista;




#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->btnadd = (gcnew System::Windows::Forms::Button());
this->txtinfo = (gcnew System::Windows::Forms::Label());
this->txtlistan = (gcnew System::Windows::Forms::Label());
this->txtitem = (gcnew System::Windows::Forms::TextBox());
this->txtlist = (gcnew System::Windows::Forms::TextBox());
this->btnclear = (gcnew System::Windows::Forms::Button());
this->btnExit = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// btnadd
//
this->btnadd->DialogResult = System::Windows::Forms::DialogResult::Yes;
this->btnadd->Location = System::Drawing::Point(232, 22);
this->btnadd->Name = L"btnadd";
this->btnadd->Size = System::Drawing::Size(75, 23);
this->btnadd->TabIndex = 0;
this->btnadd->Text = L"Add";
this->btnadd->UseVisualStyleBackColor = true;
this->btnadd->Click += gcnew System::EventHandler(this, &Form1::btnadd_Click);
//
// txtinfo
//
this->txtinfo->AutoSize = true;
this->txtinfo->Location = System::Drawing::Point(12, 29);
this->txtinfo->Name = L"txtinfo";
this->txtinfo->Size = System::Drawing::Size(94, 13);
this->txtinfo->TabIndex = 1;
this->txtinfo->Text = L"Write what to add;";
//
// txtlistan
//
this->txtlistan->AutoSize = true;
this->txtlistan->Location = System::Drawing::Point(12, 105);
this->txtlistan->Name = L"txtlistan";
this->txtlistan->Size = System::Drawing::Size(93, 13);
this->txtlistan->TabIndex = 2;
this->txtlistan->Text = L"Your shopping list.";
//
// txtitem
//
this->txtitem->Location = System::Drawing::Point(113, 24);
this->txtitem->Name = L"txtitem";
this->txtitem->Size = System::Drawing::Size(100, 20);
this->txtitem->TabIndex = 3;
this->txtitem->TextChanged += gcnew System::EventHandler(this, &Form1::txtitem_TextChanged);
//
// txtlist
//
this->txtlist->Location = System::Drawing::Point(12, 121);
this->txtlist->Multiline = true;
this->txtlist->Name = L"txtlist";
this->txtlist->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
this->txtlist->Size = System::Drawing::Size(249, 151);
this->txtlist->TabIndex = 4;
this->txtlist->TextChanged += gcnew System::EventHandler(this, &Form1::txtlist_TextChanged);
//
// btnclear
//
this->btnclear->Location = System::Drawing::Point(16, 278);
this->btnclear->Name = L"btnclear";
this->btnclear->Size = System::Drawing::Size(75, 23);
this->btnclear->TabIndex = 5;
this->btnclear->Text = L"Clear";
this->btnclear->UseVisualStyleBackColor = true;
this->btnclear->Click += gcnew System::EventHandler(this, &Form1::btnclear_Click);
//
// btnExit
//
this->btnExit->Location = System::Drawing::Point(185, 278);
this->btnExit->Name = L"btnExit";
this->btnExit->Size = System::Drawing::Size(75, 23);
this->btnExit->TabIndex = 6;
this->btnExit->Text = L"Exit";
this->btnExit->UseVisualStyleBackColor = true;
this->btnExit->Click += gcnew System::EventHandler(this, &Form1::btndone_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(319, 313);
this->Controls->Add(this->btnExit);
this->Controls->Add(this->btnclear);
this->Controls->Add(this->txtlist);
this->Controls->Add(this->txtitem);
this->Controls->Add(this->txtlistan);
this->Controls->Add(this->txtinfo);
this->Controls->Add(this->btnadd);
this->Cursor = System::Windows::Forms::Cursors::Default;
this->Name = L"Form1";
this->Text = L"Shopping list";
this->ResumeLayout(false);
this->PerformLayout();

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

Matlista = txtitem->Text;

}
private: System::Void btnadd_Click(System::Object^ sender, System::EventArgs^ e) {
Matlista = txtitem->Text;
}
private: System::Void btndone_Click(System::Object^ sender, System::EventArgs^ e) {
Application::Exit();
}
private: System::Void btnclear_Click(System::Object^ sender, System::EventArgs^ e) {
txtitem->Text = "";
txtlist->Text = "";
}
private: System::Void txtlist_TextChanged(System::Object^ sender, System::EventArgs^ e) {
txtlist->Text = Matlista;
}
};
}

mvh sickbird
Föregående tråd
Nästa tråd

3 kommentarer — skriv kommentar

Kommentarerna nedan är skrivna av användare på Fragbite. Fragbite granskar inte sanningshalten i texten och du uppmanas att själv kritiskt granska och bemöta texten. Förutsätt inte att innehållet i texterna är sanning.
Visa 3 kommentarer

Skriv en kommentar

Laddar..