Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my open menuIItem dialog box open the save file dialog box?
    primarykey
    data
    text
    <p>I made a small text editor that saves text from a <code>RichTextBox</code> into an <code>.rtf</code> file, but whenever I click the open menu option it opens the savefile dialog box. I cannot figure out why can anyone help me out?</p> <p>Here are the names for the menu dialog items. </p> <p>MenuStrip: <code>menuStrip1</code> Save: <code>saveMenu</code> Open: <code>openMenu</code> RichTextBox: <code>richTextBox1</code></p> <p>here is the code that I am working on below... </p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //save the file private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { // Text from the rich textbox rtfMain string str = richTextBox1.Text; // Create a new SaveFileDialog object using (SaveFileDialog dlgSave = new SaveFileDialog()) try { // Available file extensions dlgSave.Filter = "Rich Text Format (.rtf)|*.rtf"; // SaveFileDialog title dlgSave.Title = "Save"; // Show SaveFileDialog if (dlgSave.ShowDialog() == DialogResult.OK &amp;&amp; dlgSave.FileName.Length &gt; 0) { richTextBox1.SaveFile(dlgSave.FileName); } } catch (Exception errorMsg) { MessageBox.Show(errorMsg.Message); } } private void openMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { using (var of = new OpenFileDialog()) { of.DefaultExt = "*.rtf"; of.Filter = "RTF Files|*.rtf"; if (of.ShowDialog() == DialogResult.OK) richTextBox1.Rtf = System.IO.File.ReadAllText(of.FileName); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload