private void menuItemOpen_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.InitialDirectory = Application.ExecutablePath; openFile.Filter = "rtf files (*.rtf)|*.rtf|txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFile.FilterIndex = 1; openFile.RestoreDirectory = true; if (openFile.ShowDialog() == DialogResult.OK) { string fullName = openFile.FileName; string fileName = Path.GetFileName(fullName); if (FindDocument(fileName) != null) { MessageBox.Show("The document: " + fileName + " has already opened!"); return; } FormAbapDoc abapDoc = new FormAbapDoc(); abapDoc.Text = fileName; if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi) { abapDoc.MdiParent = this; abapDoc.Show(); } else abapDoc.Show(dockPanel); try { abapDoc.OpenFile(fullName); // abapDoc.FileName = fullName; } catch (Exception exception) { abapDoc.Close(); MessageBox.Show(exception.Message); } } }
private FormAbapDoc CreateAbapDoc() { var abapDoc = new FormAbapDoc(); return abapDoc; }