Windows Forms Anwengung



  • Hey,
    ich habe mir ein buch gekauft worin ich in einer Übung ein Button machen soll der beim klicken das label1 ändert.Doch leider startet das Programm aufgrund Fehler nicht.Was habe ich falsch gemacht?

    // zweites Project.cpp: Hauptprojektdatei.
    
    #include "stdafx.h"
    #include "Form1.h"
    
    using namespace zweitesProject;
    
    int main(array<System::String ^> ^args)
    {
    	Application::EnableVisualStyles();
    
    	Form1^ fenster = gcnew Form1();
    	Application::Run(gcnew Form1());
    
    	return 0;
    }
    
    #pragma once
    
    namespace zweitesProject {
    
    	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>
    	/// Zusammenfassung für Form1
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			this-> Text = "Erste anwendung";
    		}
    
    	protected:
    		/// <summary>
    		/// Verwendete Ressourcen bereinigen.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::Button^  button1;
    	protected: 
    
    	private:
    		/// <summary>
    		/// Erforderliche Designervariable.
    		/// </summary>
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Erforderliche Methode für die Designerunterstützung.
    		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->button1 = (gcnew System::Windows::Forms::Button());
    			this->SuspendLayout();
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
    				static_cast<System::Byte>(0)));
    			this->label1->Location = System::Drawing::Point(58, 9);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(163, 37);
    			this->label1->TabIndex = 0;
    			this->label1->Text = L"Hallo Welt";
    			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
    			this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(103, 130);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(75, 23);
    			this->button1->TabIndex = 1;
    			this->button1->Text = L"klick mich";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->BackColor = System::Drawing::Color::Silver;
    			this->ClientSize = System::Drawing::Size(283, 165);
    			this->Controls->Add(this->button1);
    			this->Controls->Add(this->label1);
    			this->Name = L"Form1";
    			this->Text = L"zweite forms anwendung";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    			 }
    	private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
    			 }
    	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    				label->Text = "Cu!";
    			 }
    	};
    }
    

    EDIT:
    GELÖST label = label1!



  • Ausserdem: Falsches Forum... C++/CLI wäre korrekt.



  • Außerdem ist das kein C++.



  • Dieser Thread wurde von Moderator/in pumuckl aus dem Forum C++ (auch C++0x) in das Forum C++/CLI mit .NET verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten