Scale windows forms window

前端 未结 3 1116
说谎
说谎 2021-01-13 22:32

It is possible to prepare the windows forms window to resize/reposition all elements depending on the window size, but I am trying to do something different.

Is it p

3条回答
  •  没有蜡笔的小新
    2021-01-13 23:01

    Your form has a Scale property. You can directly set this property and it will simultaneously affect every control on the form.

    float scaleX = ((float)formNewWidth / formBaseWidth);
    float scaleY = ((float)formNewHeight / formBaseHeight);
    this.Scale(new SizeF(scaleX, scaleY));
    

    put this in your resize event.

提交回复
热议问题