How to get form size in C#

1 Answer

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

        private void button1_Click(object sender, EventArgs e)
        {
            int formWidth = Width;
            int formHeight = Height;

            label1.Text = "Width: " + formWidth.ToString() + " Height: " + formHeight.ToString();
        }
    }
}




/*
 * run:
 *
 * "Width: 816 Height: 489"
 * 
 */

 



answered Sep 5, 2023 by avibootz

Related questions

1 answer 135 views
1 answer 90 views
90 views asked Sep 5, 2023 by avibootz
1 answer 104 views
104 views asked Aug 19, 2023 by avibootz
1 answer 177 views
1 answer 128 views
3 answers 369 views
...