private void Stichpunktesammlung_Load(object sender, EventArgs e) { //Der Optionwn_zum_Öffnen_der_Stichpunktesammlung-Dialog wird als eine Klasse hinzufügt.Die Klasse bietet einen parameterlosen Konstruktor,mit dem das Dialog-Fenster erstellt werden kann. Optionen_zum_Öffnen_der_Stichpunktesammlung optionen = new Optionen_zum_Öffnen_der_Stichpunktesammlung(); var optionenresult = optionen.ShowDialog(); if (optionenresult == DialogResult.OK) { } else if (optionenresult == DialogResult.Yes) { //Das Themadialog-Fenster wird angezeigt. ThemaDialog themadialog = new ThemaDialog(); DialogResult themaresult = themadialog.ShowDialog(); if (themaresult == DialogResult.OK) { textBox1.Text = themadialog.Thema(); listBox1.Items.Clear(); textBox2.Select(); toolStripStatusLabel1.Text = "Neues Thema : " + themadialog.Thema(); } else { toolStripStatusLabel1.Text = "Thema-Dialog abgebrochen"; } } else { //Das OpenFileDialog-Fenster wird angezeigt. OpenFileDialog opendialog = new OpenFileDialog(); opendialog.Title = "Stichpunkteliste öffnen"; opendialog.Filter = "Textdateien (*.txt) | *.txt|Alle Dateien (*.*) | *.*"; opendialog.CheckFileExists = true; opendialog.CheckPathExists = true; if (opendialog.ShowDialog() == DialogResult.OK) { listBox1.Items.Clear(); StreamReader read = new StreamReader(opendialog.FileName, System.Text.Encoding.Default); string thema = read.ReadLine(); textBox1.Text = thema; while (!read.EndOfStream) { object inhalt = read.ReadLine(); listBox1.Items.Add(inhalt); } read.Close(); this.toolStripStatusLabel1.Text = "Datei \"" + opendialog.FileName + "\"geöffnet."; } else { this.toolStripStatusLabel1.Text = "Öffnen abgebrochen"; } } }
private void neuToolStripButton_Click(object sender, EventArgs e) { ThemaDialog themadialog = new ThemaDialog(); DialogResult themaresult = themadialog.ShowDialog(); if (themaresult == DialogResult.OK) { textBox1.Text = themadialog.Thema(); listBox1.Items.Clear(); textBox2.Select(); toolStripStatusLabel1.Text = "Neues Thema : " + themadialog.Thema(); } else { toolStripStatusLabel1.Text = "Thema-Dialog abgebrochen"; } }