Zum Inhalt springen

Nadine19

Mitglieder
  • Gesamte Inhalte

    24
  • Benutzer seit

  • Letzter Besuch

  1. Ich hab es in die Parent Form geschrieben: void menuLaden_Click(object sender, EventArgs e) { if (MdiChildren.Length == 0) { ((Form2)ActiveMdiChild).Oeffnen(); } } Das funktioniert aber nicht, da das Öffnen jetzt gar nicht mehr funktioniert Mit toolStripStatusLabel1.Text möchte ich den Status in einer Statusbar im Parent Form angeben: toolStripStatusLabel1.Text = "Texteditor - Statusbar"; Wegen der Liste, die merkt ob die Datei schon geöffnet ist oder nicht, wie genau erstelle ich so eine Liste? Hab das noch nie gemacht.
  2. Und was macht der Texteditor? Schon im Verkauf erhältlich? :-)

  3. Wo genau füge ich dieses if (MdiChildren.Length == 0) ein? Hier in der Child Form? public void Oeffnen() { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = fileFilter; DialogResult dr = openFile.ShowDialog(); saveQuestion(false); if (dr == DialogResult.OK) { richTextBox1.Clear(); string path = openFile.FileName; StreamReader sr = new StreamReader(path); string line = ""; while ((line = sr.ReadLine()) != null) { richTextBox1.Text += line + "\n"; } this.strFile = openFile.FileName; textchangedAndNotSaved = false; this.SetFormTitle(); sr.Close(); } } Oder hier in der Parent Form? void menuLaden_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Oeffnen(); } Ich glaube du hast eben meinen Nachtrag übersehen, hier ist er nochmal: Wie kann ich vom Child Form auf den toolStripStatusLabel1.Text im Parent Form zugreifen?
  4. Super, jetzt funktioniert soweit alles Hab die Logik dahinter endlich verstanden. Mich stören jetzt nur noch zwei Kleinigkeiten. - Wenn man noch kein Child geöffnet hat und auf "Öffnen" klickt soll sich die ausgesuchte Datei in einem neuen Child öffnen - Wenn man eine txt Datei öffnen möchte, diese aber schon geöffnet ist, soll man zu der Geöffneten weitergeleitet werden und somit nicht "doppelt öffnen" können Hier nochmal der Code vom Parent Form: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace Editor { public partial class frmEditor : Form { public frmEditor() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; this.menuNeu.Click += new EventHandler(menuNeu_Click); this.menuSpeichern.Click += new EventHandler(menuSpeichern_Click); this.menuLaden.Click += new EventHandler(menuLaden_Click); this.menuBeenden.Click += new EventHandler(menuBeenden_Click); this.menuAllesMarkieren.Click += new EventHandler(menuAllesMarkieren_Click); } void menuNeu_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Neu(); } void menuLaden_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Oeffnen(); } void menuSpeichern_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Speichern(); } public void toolStripMenuItem1_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Speichernunter(); } public void menuBeenden_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Beenden(); } public void toolStripMenuItem6_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Undo(); } public void toolStripMenuItem5_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Redo(); } public void toolStripMenuItem4_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Cut(); } public void toolStripMenuItem3_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Copy(); } public void toolStripMenuItem7_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Paste(); } public void menuAllesMarkieren_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).SelectAll(); } public void formatToolStripMenuItem_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).FontDialog(); } public void farbeToolStripMenuItem_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).ColorDialog(); } public void toolStripMenuItem2_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).PrintDialog(); } public void toolStripButton8_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Neu(); } public void toolStripButton2_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Oeffnen(); } public void toolStripButton1_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Speichern(); } public void toolStripButton3_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Copy(); } public void toolStripButton4_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Paste(); } public void toolStripButton5_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Cut(); } public void toolStripButton6_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Undo(); } private void toolStripButton7_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).Redo(); } public void toolStripButton9_Click(object sender, EventArgs e) { ((Form2)ActiveMdiChild).PrintDialog(); } public void newChildToolStripMenuItem_Click(object sender, EventArgs e) { Form2 childForm = new Form2(); childForm.MdiParent = this; childForm.Show(); } public void cascadeToolStripMenuItem_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.Cascade); } public void horizontalToolStripMenuItem_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.TileHorizontal); } public void vertikalToolStripMenuItem_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.TileVertical); } } } Und der Code vom Child Form: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace Editor { public partial class Form2 : Form { private static string fileFilter = "Textdateien (.txt)|*.txt"; private System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument(); private bool textchangedAndNotSaved; private string strFile; public Form2() { InitializeComponent(); this.SetFormTitle(); this.textchangedAndNotSaved = false; this.StartPosition = FormStartPosition.CenterScreen; this.richTextBox1.TextChanged += new EventHandler(richTextBox1_TextChanged); this.FormClosing += new FormClosingEventHandler(Form2_FormClosing); } public void Neu() { if (saveQuestion(false)) { this.richTextBox1.Clear(); this.textchangedAndNotSaved = false; this.strFile = null; this.SetFormTitle(); } else { this.richTextBox1.Clear(); this.textchangedAndNotSaved = false; this.strFile = null; this.SetFormTitle(); } //((frmEditor)MdiParent).toolStripStatusLabel1.Text = "Texteditor - Statusbar"; } public void Oeffnen() { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = fileFilter; DialogResult dr = openFile.ShowDialog(); saveQuestion(false); if (dr == DialogResult.OK) { richTextBox1.Clear(); string path = openFile.FileName; StreamReader sr = new StreamReader(path); string line = ""; while ((line = sr.ReadLine()) != null) { richTextBox1.Text += line + "\n"; } this.strFile = openFile.FileName; textchangedAndNotSaved = false; this.SetFormTitle(); sr.Close(); } } public void Speichern() { if (richTextBox1.Text.Length == 0) return; else if (this.strFile == null || this.strFile.Length == 0) this.SaveDocument(); else this.SaveToFile(); this.SetFormTitle(); //toolStripStatusLabel1.Text = "Texteditor - Gespeichert"; } public void Speichernunter() { this.SaveDocument(); //toolStripStatusLabel1.Text = "Texteditor - Gespeichert"; } public void PrintDialog() { printDialog1.AllowSomePages = true; printDialog1.Document = docToPrint; DialogResult result = printDialog1.ShowDialog(); if (result == DialogResult.OK) { docToPrint.Print(); } } public void Beenden() { saveQuestion(true); } public void Undo() { this.richTextBox1.Undo(); } public void Redo() { this.richTextBox1.Redo(); } public void Cut() { this.richTextBox1.Cut(); } public void Copy() { this.richTextBox1.Copy(); } public void Paste() { this.richTextBox1.Paste(); } public void SelectAll() { this.richTextBox1.SelectAll(); } public void FontDialog() { FontDialog fontDialog = new FontDialog(); if (fontDialog.ShowDialog() != DialogResult.Cancel) { this.richTextBox1.Font = fontDialog.Font; } } public void ColorDialog() { ColorDialog colorDialog = new ColorDialog(); if (colorDialog.ShowDialog() != DialogResult.Cancel) { this.richTextBox1.ForeColor = colorDialog.Color; } } public void richTextBox1_TextChanged(object sender, EventArgs e) { textchangedAndNotSaved = true; this.SetFormTitle(); //toolStripStatusLabel1.Text = "Texteditor - Statusbar"; } private void SaveToFile() { try { StreamWriter sw = new StreamWriter(strFile, false); sw.Write(richTextBox1.Text); sw.Close(); } catch (Exception e) { MessageBox.Show(e.Message); return; } this.textchangedAndNotSaved = false; } private void SaveDocument() { if (this.strFile != null && this.strFile.Length > 0) saveFileDialog1.FileName = this.strFile; saveFileDialog1.Filter = "Textdateien (*.txt)|*.txt|" + "Alle Dateien (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { this.strFile = saveFileDialog1.FileName; this.SaveToFile(); } this.SetFormTitle(); } public void SetFormTitle() { if (this.strFile == null || this.strFile.Length == 0) this.Text = "Unbekannt"; else this.Text = Path.GetFileName(this.strFile); if (this.textchangedAndNotSaved == true) { if (this.strFile == null || this.strFile.Length == 0) this.Text = "Unbekannt" + "*"; else this.Text = Path.GetFileName(this.strFile) + "*"; } } public void OpenTextFile(string Filename) { richTextBox1.LoadFile(Filename); } private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = openFileDialog.FileName; if (System.IO.File.Exists(FileName)) { Form2 child = new Form2(); child.MdiParent = this; child.OpenTextFile(FileName); child.Show(); } } } private bool saveQuestion(bool last) { if (textchangedAndNotSaved) { DialogResult dr = MessageBox.Show("Der Text wurde verändert!\n\nAktuelle Änderung speichern?", "Speichern", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Yes) { saveText(); if (last) this.Dispose(); return true; } else if (dr == DialogResult.No) { if (last) this.Dispose(); else return true; } else if (dr == DialogResult.Cancel) return false; } else if (last) this.Dispose(); return false; } private bool saveText() { bool success = false; SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = fileFilter; DialogResult dr = saveFile.ShowDialog(); if (dr == DialogResult.OK) { string path = saveFile.FileName.ToString(); try { StreamWriter sw = new StreamWriter(path); sw.Write(richTextBox1.Text); sw.Flush(); sw.Close(); success = true; textchangedAndNotSaved = false; } catch (Exception) { success = false; } } return success; } private void Form2_FormClosing(object sender, FormClosingEventArgs e) { if (!saveQuestion(true)) e.Cancel = true; } } } Vielen Dank für eure Hilfe Nachtrag: Ach ja, wie kann ich vom Child Form auf den toolStripStatusLabel1.Text im Parent Form zugreifen?
  5. Ach so, jetzt verstehe ich es ein wenig besser. Aber wo genau bleibt dieser Rest: else if (this.strFile == null || this.strFile.Length == 0) this.SaveDocument(); else this.SaveToFile(); this.SetFormTitle(); toolStripStatusLabel1.Text = "Texteditor - Gespeichert"; } bei public void SaveTextFile() { if (richTextBox1.Text.Length == 0) return; else richTextBox1.SaveFile(OpenFileName); } ? Der fehlt da ja, ist aber wichtig damit mein Texteditor ordenlich funktioniert. Wie ändere ich denn z.B. das einfache Ausschneiden? private void toolStripMenuItem4_Click(object sender, EventArgs e) { this.richTextBox1.Cut(); } in etwas so in der Parent Form?: ((Form2)ActiveMdiChild).Cut();
  6. Die richTextBox ist auch schon längst draußen. Bloß wie soll ich ihm das 25 mal in meiner Anwendung sagen? Ein Beispiel: void menuSpeichern_Click(object sender, EventArgs e) { if (richTextBox1.Text.Length == 0) return; else if (this.strFile == null || this.strFile.Length == 0) this.SaveDocument(); else this.SaveToFile(); this.SetFormTitle(); toolStripStatusLabel1.Text = "Texteditor - Gespeichert"; } Was schreibe ich denn statt richTextBox1.Text.Length == 0??? Oder hier: private void farbeToolStripMenuItem_Click(object sender, EventArgs e) { ColorDialog colorDialog = new ColorDialog(); if (colorDialog.ShowDialog() != DialogResult.Cancel) { this.richTextBox1.ForeColor = colorDialog.Color; } } Was schreibe ich statt this.richTextBox1.ForeColor = colorDialog.Color? Ich stehe momentan irgendwie total auf'n Schlauch...
  7. Hab es jetzt so abgeändert wie Pointerman es geschrieben hat. Bloß wie ändern ich jetzt jedes meiner 25 this.richTextBox1 darauf ab?
  8. Vielen Dank für deine Antwort Hat mir schon ein wenig weitergeholfen. Es funktionert, aber trotzdem zeigt er mir ja immer noch in Form1 (frmEditor/Parent Form) an das this.richTextBox1 nicht existiert, weil sie ja jetzt im Child Form ist. Ich möchte ja in diesen Child Forms txt Dateien öffnen, speichern usw. können. Also das sich halt, wenn man auf "Neu" klickt ein Child Form öffnet mit einer leeren richTextBox. Wenn ich dann auf "Öffnen" klick soll sich in dieser aktiven Child Form in der richTextBox die txt Datei öffnen und auch speichern lassen. Hoffe ihr versteht was ich meine.
  9. Wie erstelle ich so eine Funktion? Tut mir leid, aber irgendwie verstehe ich es nicht. Hier ist mein Code vom frmEditor (Parent Form) zur besseren Verständnis: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace Editor { public partial class frmEditor : Form { private static string fileFilter = "Textdateien (.txt)|*.txt"; private System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument(); private bool textchangedAndNotSaved; private string strFile; public frmEditor() { InitializeComponent(); this.SetFormTitle(); this.textchangedAndNotSaved = false; this.StartPosition = FormStartPosition.CenterScreen; this.menuNeu.Click += new EventHandler(menuNeu_Click); this.menuSpeichern.Click += new EventHandler(menuSpeichern_Click); this.menuLaden.Click += new EventHandler(menuLaden_Click); this.menuBeenden.Click += new EventHandler(menuBeenden_Click); this.menuAllesMarkieren.Click += new EventHandler(menuAllesMarkieren_Click); this.richTextBox1.TextChanged += new EventHandler(richTextBox1_TextChanged); this.FormClosing += new FormClosingEventHandler(frmEditor_FormClosing); } void menuLaden_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = fileFilter; DialogResult dr = openFile.ShowDialog(); saveQuestion(false); if (dr == DialogResult.OK) { richTextBox1.Clear(); string path = openFile.FileName; StreamReader sr = new StreamReader(path); string line = ""; while ((line = sr.ReadLine()) != null) { richTextBox1.Text += line + "\n"; } this.strFile = openFile.FileName; textchangedAndNotSaved = false; this.SetFormTitle(); sr.Close(); } } void menuSpeichern_Click(object sender, EventArgs e) { if (richTextBox1.Text.Length == 0) return; else if (this.strFile == null || this.strFile.Length == 0) this.SaveDocument(); else this.SaveToFile(); this.SetFormTitle(); } private void toolStripMenuItem1_Click(object sender, EventArgs e) { this.SaveDocument(); } void menuNeu_Click(object sender, EventArgs e) { if (saveQuestion(false)) { this.richTextBox1.Clear(); this.textchangedAndNotSaved = false; this.strFile = null; this.SetFormTitle(); } else { this.richTextBox1.Clear(); this.textchangedAndNotSaved = false; this.strFile = null; this.SetFormTitle(); } } private void SaveToFile() { try { StreamWriter sw = new StreamWriter(strFile, false); sw.Write(richTextBox1.Text); sw.Close(); } catch (Exception e) { MessageBox.Show(e.Message); return; } this.textchangedAndNotSaved = false; } private void SaveDocument() { if (this.strFile != null && this.strFile.Length > 0) saveFileDialog1.FileName = this.strFile; saveFileDialog1.Filter = "Textdateien (*.txt)|*.txt|" + "Alle Dateien (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { this.strFile = saveFileDialog1.FileName; this.SaveToFile(); } this.SetFormTitle(); } public void SetFormTitle() { if (this.strFile == null || this.strFile.Length == 0) this.Text = "Texteditor - Unbekannt"; else this.Text = "Texteditor - " + Path.GetFileName(this.strFile); if (this.textchangedAndNotSaved == true) { if (this.strFile == null || this.strFile.Length == 0) this.Text = "Texteditor - Unbekannt" + "*"; else this.Text = "Texteditor - " + Path.GetFileName(this.strFile) + "*"; } } private void richTextBox1_TextChanged(object sender, EventArgs e) { textchangedAndNotSaved = true; this.SetFormTitle(); } private void frmEditor_FormClosing(object sender, FormClosingEventArgs e) { if (!saveQuestion(true)) e.Cancel = true; } private void menuBeenden_Click(object sender, EventArgs e) { saveQuestion(true); } private void toolStripMenuItem6_Click(object sender, EventArgs e) { this.richTextBox1.Undo(); } private void toolStripMenuItem5_Click(object sender, EventArgs e) { this.richTextBox1.Redo(); } private void toolStripMenuItem4_Click(object sender, EventArgs e) { this.richTextBox1.Cut(); } private void toolStripMenuItem3_Click(object sender, EventArgs e) { this.richTextBox1.Copy(); } private void toolStripMenuItem7_Click(object sender, EventArgs e) { this.richTextBox1.Paste(); } private void menuAllesMarkieren_Click(object sender, EventArgs e) { this.richTextBox1.SelectAll(); } private void formatToolStripMenuItem_Click(object sender, EventArgs e) { FontDialog fontDialog = new FontDialog(); if (fontDialog.ShowDialog() != DialogResult.Cancel) { this.richTextBox1.Font = fontDialog.Font; } } private void farbeToolStripMenuItem_Click(object sender, EventArgs e) { ColorDialog colorDialog = new ColorDialog(); if (colorDialog.ShowDialog() != DialogResult.Cancel) { this.richTextBox1.ForeColor = colorDialog.Color; } } private void toolStripMenuItem2_Click(object sender, EventArgs e) { printDialog1.AllowSomePages = true; printDialog1.Document = docToPrint; DialogResult result = printDialog1.ShowDialog(); if (result == DialogResult.OK) { docToPrint.Print(); } } private bool saveQuestion(bool last) { if (textchangedAndNotSaved) { DialogResult dr = MessageBox.Show("Der Text wurde verändert!\n\nAktuelle Änderung speichern?", "Speichern", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Yes) { saveText(); if (last) this.Dispose(); return true; } else if (dr == DialogResult.No) { if (last) this.Dispose(); else return true; } else if (dr == DialogResult.Cancel) return false; } else if (last) this.Dispose(); return false; } private bool saveText() { bool success = false; SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = fileFilter; DialogResult dr = saveFile.ShowDialog(); if (dr == DialogResult.OK) { string path = saveFile.FileName.ToString(); try { StreamWriter sw = new StreamWriter(path); sw.Write(richTextBox1.Text); sw.Flush(); sw.Close(); success = true; textchangedAndNotSaved = false; } catch (Exception) { success = false; } } return success; } private void toolStripButton2_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = fileFilter; DialogResult dr = openFile.ShowDialog(); if (dr == DialogResult.OK) { richTextBox1.Clear(); string path = openFile.FileName; StreamReader sr = new StreamReader(path); string line = ""; while ((line = sr.ReadLine()) != null) { richTextBox1.Text += line + "\n"; } this.strFile = openFile.FileName; textchangedAndNotSaved = false; this.SetFormTitle(); sr.Close(); } } private void toolStripButton1_Click(object sender, EventArgs e) { if (richTextBox1.Text.Length == 0) return; else if (this.strFile == null || this.strFile.Length == 0) this.SaveDocument(); else this.SaveToFile(); this.SetFormTitle(); } private void toolStripButton3_Click(object sender, EventArgs e) { this.richTextBox1.Copy(); } private void toolStripButton4_Click(object sender, EventArgs e) { this.richTextBox1.Paste(); } private void toolStripButton5_Click(object sender, EventArgs e) { this.richTextBox1.Cut(); } private void toolStripButton6_Click(object sender, EventArgs e) { this.richTextBox1.Undo(); } private void toolStripButton8_Click(object sender, EventArgs e) { if (saveQuestion(false)) { this.richTextBox1.Clear(); this.textchangedAndNotSaved = false; this.strFile = null; this.SetFormTitle(); } else { this.richTextBox1.Clear(); this.textchangedAndNotSaved = false; this.strFile = null; this.SetFormTitle(); } } private void toolStripButton9_Click(object sender, EventArgs e) { printDialog1.AllowSomePages = true; printDialog1.Document = docToPrint; DialogResult result = printDialog1.ShowDialog(); if (result == DialogResult.OK) { docToPrint.Print(); } } private void newChildToolStripMenuItem_Click(object sender, EventArgs e) { // Declare the child form as a new one. Form2 childForm = new Form2(); // Set the main form as a parent form. childForm.MdiParent = this; // Show the child form. childForm.Show(); } private void cascadeToolStripMenuItem_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.Cascade); } private void horizontalToolStripMenuItem_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.TileHorizontal); } private void vertikalToolStripMenuItem_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.TileVertical); } } }
  10. Wie genau soll ich das anstellen? Ich hab in meiner Parent Form min. 25 mal this.richTextBox1 stehen. Soll ich das zu Program.frm2.richTextBox1 ändern?
  11. Ich bins mal wieder, also mein Texteditor funktioniert soweit Jetzt soll ich ein Multi Document Interface erstellen um somit mehrere txt Dateien gleichzeitig öffnen und bearbeiten zu können. Hab mich schon über MDI informiert und auch schon eins gebastelt, das funktioniert, bloß wie ich das auf den Texteditor anwende ist mir noch nicht so ganz klar. Ich brauch ja ein Parent Form (frmEditor) und ein Child Form (Form2). Auf dem Parent Form befindet sich bei mir das Menü, Toolbar usw. und auf dem Child Form habe ich meine richTextBox1 eingefügt die vorher auf dem Parent Form war. Nun meckert er ja, das sich auf dem Parent Form eben diese richTextBox1 nicht mehr finden lässt. Wie sage ich ihm jetzt das sich die richTextBox1 im Child Form befindet? Achtung! Ich bin totale Anfängerin in C#!
  12. Danke für den Link ! Werd mich mal dran machen.
  13. Das mit e.Cancel hab ich auch gelöst, hab es einfach in Application.Exit(); geändert. Jetzt erscheint die Message Box, aber wenn ich auf "Wollen Sie speichern?" "Ja" klicke passiert nichts, da sollte sich doch dann ein SaveFileDialog melden? Wie kann ich das am besten anstellen? Hier nochmal der Code: if (this.textvorhanden == true) { DialogResult dr = MessageBox.Show("Wollen Sie Speichern?", "Speichern", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Yes) { //Speichern } else if (dr == DialogResult.No) { //Beenden this.Dispose(); } else if (dr == DialogResult.Cancel) { //Beenden abbrechen Application.Exit(); //e.Cancel = true; } }
  14. Die erste Frage mit MessageBoxButtons.YesNoCancel hat sich geklärt. Bei MessageBoxButtons war Box klein geschrieben und bei YesNoCancel stand Cancle.

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...