textbox in variable speichern und dann in eineini datei
-
hi,
Ich habe gerade mein erstes Windows FOrm erstellt nun wollte ich wissen wie ich 2 saschen shacfee. Ihch habe 1 Button und ine Textbox. Und ich will das wenn man auf dies textbox klixkt dass mab dann einen fileopendialog bekommt bbei dem man nur exe anwendungen auswählen kann und wenn man dann auf öffnen geht dass dann der Pfad in die textbox kopiert wird. Und wenn man dann in meiner Menüleiste auf abspeichern klickt dass dann der pfad in eine ini Datei gespeichert wird. Geht dass??? Ach ja und wie shcaffe ich es wenn man einen menustrip erstellt dass wen man dann auf ein itmen klickt mit unteritems dass dann das erste item in der leiste angezeigt bleibt??mein bisheriger Code vom form1
#pragma once namespace first { 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(); // //TODO: Konstruktorcode hier hinzufügen. // } protected: /// <summary> /// Verwendete Ressourcen bereinigen. /// </summary> ~Form1() { if (components) { delete components; } } protected: private: System::Windows::Forms::ToolStripMenuItem^ toolStripMenuItem1; private: System::Windows::Forms::ToolStripMenuItem^ hilfeToolStripMenuItem; private: System::Windows::Forms::MenuStrip^ menuStrip1; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::ToolStripMenuItem^ dateiToolStripMenuItem1; private: System::Windows::Forms::ToolStripComboBox^ dateiToolStripMenuItem; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::ComboBox^ comboBox1; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::TextBox^ textBox3; private: System::Windows::Forms::TextBox^ textBox4; private: System::Windows::Forms::TextBox^ textBox5; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::ComboBox^ comboBox2; private: System::Windows::Forms::ComboBox^ comboBox3; private: System::Windows::Forms::Button^ button5; private: System::Windows::Forms::Button^ button6; private: System::Windows::Forms::Button^ button7; private: System::Windows::Forms::Button^ button8; private: System::ComponentModel::IContainer^ components; protected: 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->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->hilfeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip()); this->dateiToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->dateiToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripComboBox()); this->label1 = (gcnew System::Windows::Forms::Label()); this->button1 = (gcnew System::Windows::Forms::Button()); this->label2 = (gcnew System::Windows::Forms::Label()); this->comboBox1 = (gcnew System::Windows::Forms::ComboBox()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->textBox3 = (gcnew System::Windows::Forms::TextBox()); this->textBox4 = (gcnew System::Windows::Forms::TextBox()); this->textBox5 = (gcnew System::Windows::Forms::TextBox()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->comboBox2 = (gcnew System::Windows::Forms::ComboBox()); this->comboBox3 = (gcnew System::Windows::Forms::ComboBox()); this->button5 = (gcnew System::Windows::Forms::Button()); this->button6 = (gcnew System::Windows::Forms::Button()); this->button7 = (gcnew System::Windows::Forms::Button()); this->button8 = (gcnew System::Windows::Forms::Button()); this->menuStrip1->SuspendLayout(); this->SuspendLayout(); // // toolStripMenuItem1 // this->toolStripMenuItem1->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->hilfeToolStripMenuItem}); this->toolStripMenuItem1->Name = L"toolStripMenuItem1"; this->toolStripMenuItem1->Size = System::Drawing::Size(44, 22); this->toolStripMenuItem1->Text = L"Hilfe"; // // hilfeToolStripMenuItem // this->hilfeToolStripMenuItem->Name = L"hilfeToolStripMenuItem"; this->hilfeToolStripMenuItem->Size = System::Drawing::Size(99, 22); this->hilfeToolStripMenuItem->Text = L"Hilfe"; // // menuStrip1 // this->menuStrip1->BackColor = System::Drawing::Color::WhiteSmoke; this->menuStrip1->Font = (gcnew System::Drawing::Font(L"Arial", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->toolStripMenuItem1, this->dateiToolStripMenuItem1}); this->menuStrip1->Location = System::Drawing::Point(0, 0); this->menuStrip1->Name = L"menuStrip1"; this->menuStrip1->Padding = System::Windows::Forms::Padding(5, 1, 0, 1); this->menuStrip1->Size = System::Drawing::Size(393, 24); this->menuStrip1->TabIndex = 0; this->menuStrip1->Text = L"menuStrip1"; this->menuStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::menuStrip1_ItemClicked); // // dateiToolStripMenuItem1 // this->dateiToolStripMenuItem1->Name = L"dateiToolStripMenuItem1"; this->dateiToolStripMenuItem1->Size = System::Drawing::Size(48, 22); this->dateiToolStripMenuItem1->Text = L"Datei"; // // textBox1 // this->textBox1->BackColor = System::Drawing::SystemColors::HighlightText; this->textBox1->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->textBox1->Location = System::Drawing::Point(12, 59); this->textBox1->MaximumSize = System::Drawing::Size(120, 30); this->textBox1->MinimumSize = System::Drawing::Size(4, 20); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(100, 22); this->textBox1->TabIndex = 1; // // dateiToolStripMenuItem // this->dateiToolStripMenuItem->Name = L"dateiToolStripMenuItem"; this->dateiToolStripMenuItem->Size = System::Drawing::Size(75, 23); this->dateiToolStripMenuItem->Text = L"Datei"; // // label1 // this->label1->AutoSize = true; this->label1->BackColor = System::Drawing::Color::Transparent; this->label1->Font = (gcnew System::Drawing::Font(L"Arial", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->label1->Location = System::Drawing::Point(11, 33); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(147, 15); this->label1->TabIndex = 2; this->label1->Text = L"Programmverzeichnisse"; // // button1 // this->button1->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button1->Location = System::Drawing::Point(118, 57); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(53, 24); this->button1->TabIndex = 3; this->button1->Text = L"..."; this->button1->UseVisualStyleBackColor = true; // // label2 // this->label2->AutoSize = true; this->label2->BackColor = System::Drawing::Color::Transparent; this->label2->Font = (gcnew System::Drawing::Font(L"Arial", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label2->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->label2->Location = System::Drawing::Point(261, 33); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(53, 15); this->label2->TabIndex = 17; this->label2->Text = L"Hotkeys"; // // comboBox1 // this->comboBox1->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->comboBox1->FormattingEnabled = true; this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"Herunterfahren", L"Neu starten", L"Energie sparen"}); this->comboBox1->Location = System::Drawing::Point(12, 199); this->comboBox1->Name = L"comboBox1"; this->comboBox1->Size = System::Drawing::Size(100, 24); this->comboBox1->TabIndex = 18; // // textBox2 // this->textBox2->BackColor = System::Drawing::SystemColors::HighlightText; this->textBox2->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->textBox2->Location = System::Drawing::Point(12, 87); this->textBox2->MaximumSize = System::Drawing::Size(120, 30); this->textBox2->MinimumSize = System::Drawing::Size(4, 20); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(100, 22); this->textBox2->TabIndex = 21; // // textBox3 // this->textBox3->BackColor = System::Drawing::SystemColors::HighlightText; this->textBox3->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->textBox3->Location = System::Drawing::Point(12, 115); this->textBox3->MaximumSize = System::Drawing::Size(120, 30); this->textBox3->MinimumSize = System::Drawing::Size(4, 20); this->textBox3->Name = L"textBox3"; this->textBox3->Size = System::Drawing::Size(100, 22); this->textBox3->TabIndex = 22; // // textBox4 // this->textBox4->BackColor = System::Drawing::SystemColors::HighlightText; this->textBox4->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->textBox4->Location = System::Drawing::Point(12, 143); this->textBox4->MaximumSize = System::Drawing::Size(120, 30); this->textBox4->MinimumSize = System::Drawing::Size(4, 20); this->textBox4->Name = L"textBox4"; this->textBox4->Size = System::Drawing::Size(100, 22); this->textBox4->TabIndex = 23; // // textBox5 // this->textBox5->BackColor = System::Drawing::SystemColors::HighlightText; this->textBox5->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->textBox5->Location = System::Drawing::Point(12, 171); this->textBox5->MaximumSize = System::Drawing::Size(120, 30); this->textBox5->MinimumSize = System::Drawing::Size(4, 20); this->textBox5->Name = L"textBox5"; this->textBox5->Size = System::Drawing::Size(100, 22); this->textBox5->TabIndex = 24; // // button2 // this->button2->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button2->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button2->Location = System::Drawing::Point(118, 113); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(53, 24); this->button2->TabIndex = 25; this->button2->Text = L"..."; this->button2->UseVisualStyleBackColor = true; // // button3 // this->button3->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button3->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button3->Location = System::Drawing::Point(118, 85); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(53, 24); this->button3->TabIndex = 26; this->button3->Text = L"..."; this->button3->UseVisualStyleBackColor = true; // // button4 // this->button4->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button4->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button4->Location = System::Drawing::Point(118, 141); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(53, 24); this->button4->TabIndex = 27; this->button4->Text = L"..."; this->button4->UseVisualStyleBackColor = true; // // comboBox2 // this->comboBox2->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->comboBox2->FormattingEnabled = true; this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"Herunterfahren", L"Neu starten", L"Energie sparen"}); this->comboBox2->Location = System::Drawing::Point(12, 259); this->comboBox2->Name = L"comboBox2"; this->comboBox2->Size = System::Drawing::Size(100, 24); this->comboBox2->TabIndex = 28; // // comboBox3 // this->comboBox3->Font = (gcnew System::Drawing::Font(L"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->comboBox3->FormattingEnabled = true; this->comboBox3->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"Herunterfahren", L"Neu starten", L"Energie sparen"}); this->comboBox3->Location = System::Drawing::Point(12, 229); this->comboBox3->Name = L"comboBox3"; this->comboBox3->Size = System::Drawing::Size(100, 24); this->comboBox3->TabIndex = 29; // // button5 // this->button5->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button5->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button5->Location = System::Drawing::Point(118, 259); this->button5->Name = L"button5"; this->button5->Size = System::Drawing::Size(53, 24); this->button5->TabIndex = 30; this->button5->Text = L"..."; this->button5->UseVisualStyleBackColor = true; // // button6 // this->button6->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button6->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button6->Location = System::Drawing::Point(118, 229); this->button6->Name = L"button6"; this->button6->Size = System::Drawing::Size(53, 24); this->button6->TabIndex = 31; this->button6->Text = L"..."; this->button6->UseVisualStyleBackColor = true; // // button7 // this->button7->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button7->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button7->Location = System::Drawing::Point(118, 199); this->button7->Name = L"button7"; this->button7->Size = System::Drawing::Size(53, 24); this->button7->TabIndex = 32; this->button7->Text = L"..."; this->button7->UseVisualStyleBackColor = true; // // button8 // this->button8->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->button8->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button8->Location = System::Drawing::Point(118, 171); this->button8->Name = L"button8"; this->button8->Size = System::Drawing::Size(53, 22); this->button8->TabIndex = 33; this->button8->Text = L"..."; this->button8->UseVisualStyleBackColor = true; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(5, 10); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->BackColor = System::Drawing::Color::White; this->ClientSize = System::Drawing::Size(393, 343); this->Controls->Add(this->button8); this->Controls->Add(this->button7); this->Controls->Add(this->button6); this->Controls->Add(this->button5); this->Controls->Add(this->comboBox3); this->Controls->Add(this->comboBox2); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->textBox5); this->Controls->Add(this->textBox4); this->Controls->Add(this->textBox3); this->Controls->Add(this->textBox2); this->Controls->Add(this->comboBox1); this->Controls->Add(this->label2); this->Controls->Add(this->button1); this->Controls->Add(this->label1); this->Controls->Add(this->textBox1); this->Controls->Add(this->menuStrip1); this->Font = (gcnew System::Drawing::Font(L"Arial", 6, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->ForeColor = System::Drawing::SystemColors::ControlLightLight; this->MainMenuStrip = this->menuStrip1; this->Margin = System::Windows::Forms::Padding(2); this->Name = L"Form1"; this->Text = L"Hotkeymanager"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->menuStrip1->ResumeLayout(false); this->menuStrip1->PerformLayout(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void menuStrip1_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) { } private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void label1_Click_1(System::Object^ sender, System::EventArgs^ e) { } private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) { } }; }
Ich hoffe ihr könnt mir meine Fragen beantowrten.
MFG Franz
-
private void Button_Click(object sender, EventArgs e)
{
openFileDialog.Filter = "executable (.exe)|.exe";
openFileDialog.FileName = "";
openFileDialog.Title = "";if (openFileDialog.ShowDialog() == DialogResult.OK)
TextBox a = openFileDialog.Filename}