Problemme bei Programm mit VC++ 2005!



  • Hi,
    Ich möchte ein einfaches Grafisches Programm erstellen das etwas ausrechnet doch ich bekomm denn inhalt aus den TextBoxen nicht ausgelesen Beim alten VC konnte man einfach TextBox.Text schreiben doch das geht irgendwie nicht merh habe schon
    :

    System::Windows::Forms::TextBox
    System::Windows::Forms::TextBox()

    ausprobiert doch bei keinem Funktioniert es hier mal der Komplette Code:

    #pragma once
    
    namespace ohmrechner {
    
    	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
    	///
    	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
    	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
    	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
    	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
    	///          arbeiten, die diesem Formular zugewiesen sind.
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    
    		}
    
    	protected:
    		/// <summary>
    		/// Verwendete Ressourcen bereinigen.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
    	protected: 
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::TextBox^  lang;
    	private: System::Windows::Forms::TextBox^  quer;
    	private: System::Windows::Forms::Label^  label2;
    	private: System::Windows::Forms::TextBox^  widerstand;
    	private: System::Windows::Forms::Label^  label3;
    	private: System::Windows::Forms::Button^  button1;
    	private: System::Windows::Forms::TextBox^  result;
    	private: System::Windows::Forms::Label^  label4;
    
    	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->lang = (gcnew System::Windows::Forms::TextBox());
    			this->quer = (gcnew System::Windows::Forms::TextBox());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->widerstand = (gcnew System::Windows::Forms::TextBox());
    			this->label3 = (gcnew System::Windows::Forms::Label());
    			this->button1 = (gcnew System::Windows::Forms::Button());
    			this->result = (gcnew System::Windows::Forms::TextBox());
    			this->label4 = (gcnew System::Windows::Forms::Label());
    			this->SuspendLayout();
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(11, 8);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(138, 14);
    			this->label1->TabIndex = 1;
    			this->label1->Text = L"Länge des Kabels/Drahtes:";
    			// 
    			// lang
    			// 
    			this->lang->Location = System::Drawing::Point(12, 25);
    			this->lang->Name = L"lang";
    			this->lang->Size = System::Drawing::Size(228, 20);
    			this->lang->TabIndex = 2;
    			// 
    			// quer
    			// 
    			this->quer->Location = System::Drawing::Point(12, 82);
    			this->quer->Name = L"quer";
    			this->quer->Size = System::Drawing::Size(225, 20);
    			this->quer->TabIndex = 3;
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(14, 63);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(170, 14);
    			this->label2->TabIndex = 4;
    			this->label2->Text = L"Queryschnitt des Kabels/Drahtes:";
    			// 
    			// widerstand
    			// 
    			this->widerstand->Location = System::Drawing::Point(14, 138);
    			this->widerstand->Name = L"widerstand";
    			this->widerstand->Size = System::Drawing::Size(222, 20);
    			this->widerstand->TabIndex = 5;
    			// 
    			// label3
    			// 
    			this->label3->AutoSize = true;
    			this->label3->Location = System::Drawing::Point(14, 121);
    			this->label3->Name = L"label3";
    			this->label3->Size = System::Drawing::Size(132, 14);
    			this->label3->TabIndex = 6;
    			this->label3->Text = L"Widerstand des Materials:";
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(18, 175);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(165, 26);
    			this->button1->TabIndex = 7;
    			this->button1->Text = L"Ausrechnen";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    			// 
    			// result
    			// 
    			this->result->Location = System::Drawing::Point(12, 236);
    			this->result->Name = L"result";
    			this->result->Size = System::Drawing::Size(223, 20);
    			this->result->TabIndex = 8;
    			// 
    			// label4
    			// 
    			this->label4->AutoSize = true;
    			this->label4->Location = System::Drawing::Point(14, 214);
    			this->label4->Name = L"label4";
    			this->label4->Size = System::Drawing::Size(106, 14);
    			this->label4->TabIndex = 9;
    			this->label4->Text = L"Leitungswiderstand:";
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 14);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(266, 326);
    			this->Controls->Add(this->label4);
    			this->Controls->Add(this->result);
    			this->Controls->Add(this->button1);
    			this->Controls->Add(this->label3);
    			this->Controls->Add(this->widerstand);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->quer);
    			this->Controls->Add(this->lang);
    			this->Controls->Add(this->label1);
    			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
    			this->Name = L"Form1";
    			this->Text = L"Widerstandsrechner";
    			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 button1_Click(System::Object^  sender, System::EventArgs^  e) {
    			 System::Windows::Forms::TextBox->result.Text = System::Windows::Forms::TextBox->lang.Text;
    
    		 }
    };
    }
    

    Hoffe ihr könnt mir helfen!

    MFG ReduX



  • Ach herrje. Setzt Dich mal damit auseinander, was eine Klasse und was eine Instanz ist.

    Der relevante Code muss lauten:

    result->Text = lang->Text;
    

    Das gehört übrigens in ein anderes Unterforum.



  • Hi,
    Danke für deine Antwort , funktioniert so!
    Bin noch Anfänger und mit dem Tutorial das ich gerade lese bin ich nochnicht bis zu classen etc. gekommen!

    MFG ReduX



  • Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ 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