我在windows模式下使用vb.net,需要一些设计/格式化方面的帮助。
我有一个图像作为背景,图像完全以设计模式显示(不是运行时)但是在运行时窗口调整大小并变得比图像小,这意味着用户必须在物理上调整窗口大小以使界面适合。我将如何使窗口以正确的大小启动,以允许完全看到图像/界面。
请参阅下面的图片以获得更好的主意。
答案 0 :(得分:1)
尝试使用表单的 BackgroundImageLayout 属性。指定拉伸或缩放。
答案 1 :(得分:1)
这会将图像置于表单中心,将表单大小调整为图像大小,使表单居中并防止表单调整大小
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With Me
.BackgroundImageLayout = ImageLayout.Center
.Width = .BackgroundImage.Width
.Height = .BackgroundImage.Height
.Left = (Screen.FromControl(Me).WorkingArea.Width - Me.Width) / 2
.Top = (Screen.FromControl(Me).WorkingArea.Height - Me.Height) / 2
.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
.MaximizeBox = False
End With
End Sub