I making a small office word like program. I have four things. A menu bar containing File>Open,Save,Exit. I want to create a short cut for open, save. Could someone help me how to do that. this is my code

namespace Texteditor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog();
            DialogResult result = saveFile.ShowDialog();

            if (result == DialogResult.Cancel)
                return;

            string strFilename = saveFile.FileName;
            System.IO.StreamWriter sw = System.IO.File.CreateText(strFilename);
            sw.Write(textBox1.Text);
            sw.Close();
 
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileChooser = new OpenFileDialog();
            DialogResult result = fileChooser.ShowDialog();

            if (result == DialogResult.Cancel)
                return;

            string strFilename = fileChooser.FileName;
             
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
           
        }

Could someone also help me with opening a file. This is all i need. my Code is

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileChooser = new OpenFileDialog();
            DialogResult result = fileChooser.ShowDialog();

            if (result == DialogResult.Cancel)
                return;

            string strFilename = fileChooser.FileName;
            StreamReader reader = File.OpenText(strFilename);
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog();
            DialogResult result = saveFile.ShowDialog();

            if (result == DialogResult.Cancel)
                return;

            string strFilename = saveFile.FileName;
            System.IO.StreamWriter sw = System.IO.File.CreateText(strFilename);
            sw.Write(word.Text);
            sw.Close();
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

The ToolStripMenuItem class has a ShortcutKeys property.
Just set this to what you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.