Willkommen
myGully
Links
Forum
07.07.10, 15:59
#1
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Wie Form2 per Button von Form 1 öffnen?
Hallo alle Mitewinander.
Ich habe das problem das ich es irgendiwe nicht hinbekomme
die 2. Form per Bottun von der 1. Form zu öffnen.
Vieleicht könnt ihr mir ja helfen.
Ich bedanke mich schonmal für die Antworten im Voraus.
MfG moin2010
07.07.10, 17:48
#2
Banned
Registriert seit: Sep 2008
Beiträge: 15
Bedankt: 5.160
Leider gibst du wenige detail um was es sich handelt was für Programm und was du machen willst..
da muss ein syntaxfehler sein ..! poste die code hier oder per PN...
MfG ilumi...
07.07.10, 18:22
#3
Registriert seit: Dec 2009
Beiträge: 792
Bedankt: 49
Also wie iluminator schon sagte sind es ein bisschen zu wenig Info..aber da das ja eigentlich eine simple Frage ist, denke ich mal hast du Visual Basic..also wenn ja dann versuch mal auf diesen Button einen Doppelklick zu machen, dann kommst du in den Codebereich und den Button-Click Event. Dort gibst du dann ein:
natürlich muss davor aber schon eine Form2.vb vorhanden sein..wenn du nicht Visual Basic hast dann wäre es gut wenn du uns sagst welches du hast^^
08.07.10, 13:56
#4
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Ich habe Form2.Show schon versucht und da hat es nicht geklappt.
Ich benutze Visual Studio 2010 Express.
Form2 habe ich auch eigefügt bei Form1.
Das ist der code für den button:
Zitat:
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
Form2.Show
}
};
}
Dan kommen die Fehlermeldungen:
Fehler 1 error C2143: Syntaxfehler: Es fehlt ';' vor '.' Zeile 231
Fehler 2 error C2143: Syntaxfehler: Es fehlt ';' vor '.' Zeile 231
Hier ist noch mal der Code der Form1 Datei:
Zitat:
#pragma once
#include "Form2.h"
namespace Rechner11by*** {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System: ata;
using namespace System: rawing;
/// <summary>
/// Zusammenfassung für Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Konstruktorcode hier hinzufügen.
//
}
protected:
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms: extBox^ textBox1;
private: System::Windows::Forms: extBox^ textBox2;
private: System::Windows::Forms: extBox^ textBox3;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::NotifyIcon^ notifyIcon1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::ComponentModel::IContainer^ components;
private:
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
#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->components = (gcnew System::ComponentModel::Container());
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->button1 = (gcnew System::Windows::Forms::Button());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox1 = (gcnew System::Windows::Forms: extBox());
this->textBox2 = (gcnew System::Windows::Forms: extBox());
this->textBox3 = (gcnew System::Windows::Forms: extBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->notifyIcon1 = (gcnew System::Windows::Forms::NotifyIcon(this->components));
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System: rawing::Point(408, 63);
this->button1->Name = L"button1";
this->button1->Size = System: rawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"Ausrechnen";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(4) {L"plus", L"minus", L"mal", L"geteilt durch"});
this->comboBox1->Location = System: rawing::Point(175, 65);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System: rawing::Size(121, 21);
this->comboBox1->TabIndex = 1;
//
// textBox1
//
this->textBox1->Location = System: rawing::Point(69, 66);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System: rawing::Size(100, 20);
this->textBox1->TabIndex = 2;
//
// textBox2
//
this->textBox2->Location = System: rawing::Point(302, 64);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System: rawing::Size(100, 20);
this->textBox2->TabIndex = 3;
//
// textBox3
//
this->textBox3->Location = System: rawing::Point(69, 106);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System: rawing::Size(333, 20);
this->textBox3->TabIndex = 4;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System: rawing::Point(12, 109);
this->label1->Name = L"label1";
this->label1->Size = System: rawing::Size(51, 13);
this->label1->TabIndex = 5;
this->label1->Text = L"Ergebnis:";
//
// notifyIcon1
//
this->notifyIcon1->Icon = (cli::safe_cast<System: rawing::Icon^ >(resources->GetObject(L"notifyIcon1.Icon")));
this->notifyIcon1->Text = L"Taschenrechner 1.1";
this->notifyIcon1->Visible = true;
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System: rawing::Point(96, 50);
this->label2->Name = L"label2";
this->label2->Size = System: rawing::Size(37, 13);
this->label2->TabIndex = 6;
this->label2->Text = L"Zahl 1";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System: rawing::Point(332, 50);
this->label3->Name = L"label3";
this->label3->Size = System: rawing::Size(37, 13);
this->label3->TabIndex = 7;
this->label3->Text = L"Zahl 2";
//
// button2
//
this->button2->Location = System: rawing::Point(302, 176);
this->button2->Name = L"button2";
this->button2->Size = System: rawing::Size(75, 23);
this->button2->TabIndex = 8;
this->button2->Text = L"Schließen";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System: rawing::Point(94, 176);
this->button3->Name = L"button3";
this->button3->Size = System: rawing::Size(75, 23);
this->button3->TabIndex = 9;
this->button3->Text = L"Info";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// Form1
//
this->AutoScaleDimensions = System: rawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System: rawing::Size(502, 224);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->button1);
this->Cursor = System::Windows::Forms::Cursors::Arrow;
this->Icon = (cli::safe_cast<System: rawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"Form1";
this->Text = L"Taschenrechner 1.1";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if (comboBox1->SelectedItem == comboBox1->Items[0]) //addieren
textBox3->Text = System::Convert: oString(System::Convert: oInt32 (textBox1->Text) + System::Convert: oInt32(textBox2->Text));
if (comboBox1->SelectedItem == comboBox1->Items[1]) //subtrahieren
textBox3->Text = System::Convert: oString(System::Convert: oInt32 (textBox1->Text) - System::Convert: oInt32(textBox2->Text));
if (comboBox1->SelectedItem == comboBox1->Items[2]) //multipliezieren
textBox3->Text = System::Convert: oString(System::Convert: oInt32 (textBox1->Text) * System::Convert: oInt32(textBox2->Text));
if (comboBox1->SelectedItem == comboBox1->Items[3]) //dividieren
textBox3->Text = System::Convert: oString(System::Convert: oDoubl e(textBox1->Text) / System::Convert: oDouble(textBox2->Text));
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
this->Close();
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
Form2.Show
}
};
}
08.07.10, 14:47
#5
Registriert seit: Dec 2009
Beiträge: 792
Bedankt: 49
Zitat:
Zitat von
moin2010
Dan kommen die Fehlermeldungen:
Fehler 1 error C2143: Syntaxfehler: Es fehlt ';' vor '.' Zeile 231
Fehler 2 error C2143: Syntaxfehler: Es fehlt ';' vor '.' Zeile 231
Liest du dir eigentlich die Fehlermeldungen durch? Da steht doch dass da ein ";" fehlt.
Außerdem weiß ich immer noch nicht welche Sprache du benutzt..C++? Hab leider nur Basic, aber kannst ja mal versuchen
zu machen..ich würd an deiner Stelle auch lieber erstmal mit Visual Basic anfangen ist viel leichter..
__________________
To succeed you have to stop being ordinary and be legen - wait for it - dary.
08.07.10, 14:50
#6
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Form2.Show; habe ich ja auch schon probiert.
Ok.
Ich probiere dan mal Visual Basic aus.
Und die Fehlermeldungen lese ich mir natürlich auch durch.
Sry.
Ich benutze Visual C++ 2010 Express.
Geht das auch?
08.07.10, 14:57
#7
Registriert seit: Dec 2009
Beiträge: 792
Bedankt: 49
Ja das ist C++ ist eigentlich schwieriger als Basic..naja ok also dann weiß ich ja dass du c++ hast also müsste das gehen, also doppelklick auf den Button um ins Click_Event zu kommen und dann schreibst du rein:
Aber kannst ja trotzdem mal Visual Basic probieren, das geht viel leichter: [
Link nur für registrierte Mitglieder sichtbar. Bitte einloggen oder neu registrieren ]
__________________
To succeed you have to stop being ordinary and be legen - wait for it - dary.
08.07.10, 15:14
#8
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Jetzt habe ich nur noch die Fehlermeldung:
Fehler 102 error C2143: Syntaxfehler: Es fehlt ';' vor '->'
Ich habe auch diesen Fehler ausprobiert zu begleichen aber geht nicht.
08.07.10, 15:16
#9
Registriert seit: Dec 2009
Beiträge: 792
Bedankt: 49
Ich seh deinen ganzen Code nicht..erstell mal ein leeres neues Projekt und tu dann auf deine Form ein Button und doppelklick auf ihn:
oder schau ob du nicht noch irgendwo im Code was hast wo du ein ; vergessen hast..
Edit: Also wie gesagt ich hab kein C++, aber wenn der Code oben net geht dann versuch mal das:
Code:
Form2^ frm = gcnew Form2();
frm->Show();
__________________
To succeed you have to stop being ordinary and be legen - wait for it - dary.
08.07.10, 15:34
#10
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Ok Danke.
Der 2. Code von dir hat funktioniert.
08.07.10, 15:36
#11
Registriert seit: Dec 2009
Beiträge: 792
Bedankt: 49
OK gut, jedoch würde ich doch lieber Visual Basic 2010 Express benutzen, da C++ viel schwieriger ist..
__________________
To succeed you have to stop being ordinary and be legen - wait for it - dary.
08.07.10, 15:49
#12
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Ich habe esw auch schon gedownloaded und es intalliert auch gerade.
Aber Danke nochmal.
08.07.10, 15:52
#13
Registriert seit: Dec 2009
Beiträge: 792
Bedankt: 49
OK
und wenn Probleme sind kannst dich ja wieder melden, bei Basic könnte ich dir mehr helfen als bei C++
__________________
To succeed you have to stop being ordinary and be legen - wait for it - dary.
08.07.10, 15:59
#14
Erfahrener Newbie
Registriert seit: Jul 2010
Beiträge: 120
Bedankt: 1
Ok mache ich auf jeden Fall wen ich ein Problem habe.
Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren
HTML-Code ist Aus .
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:34 Uhr.
().