How to get the size of a Winforms Form titlebar height?

后端 未结 5 516
独厮守ぢ
独厮守ぢ 2021-02-01 01:59

So if it\'s toolwindow or a minimizable form, I want to be able to get its height programmatically.

Is this possible? If so how?

5条回答
  •  死守一世寂寞
    2021-02-01 02:41

    In my case, I had to change the height of the form so that it was just below one of the controls, I noticed that

      int titleHeight = this.Height - screenRectangle.Height;
    

    returns 39 while the accepted answer:

      int titleHeight =  screenRectangle.Top - this.Top;
    

    returns 31

    maybe because of form's bottom border.

提交回复
热议问题