How to minimize form on press m in C#

1 Answer

0 votes
using System;

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

            label1.Text = this.WindowState.ToString();
        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            // Set form KeyPreview property to True

            if (e.KeyChar == 'm')
            {
                this.WindowState = FormWindowState.Minimized;
                label1.Text = this.WindowState.ToString() + " : " + e.KeyChar.ToString();
            }
        }
    }
}



/*
 * run:
 * 
 * Normal
 * Minimized : m
 * 
 */

 



answered Jul 27, 2023 by avibootz

Related questions

1 answer 117 views
1 answer 96 views
1 answer 139 views
139 views asked Jul 27, 2023 by avibootz
1 answer 270 views
3 answers 495 views
...