老师,我将论坛中的代码
If e.Form.Width> 0 AndAlso e.Form.height > 0 Then
vars("width") = e.Form.width
vars("height") = e.Form.height
End If
If e.Form.width > 0 AndAlso e.Form.height > 0 Then
e.Form.StopRedraw
For Each c As Winform.Control In e.Form.Controls
c.Left = c.Left * (e.Form.Width / vars("width"))
c.Top = c.Top * (e.Form.Height / vars("height"))
c.Width = c.Width * (e.Form.Width / vars("width"))
c.Height = c.Height * (e.Form.Height / vars("height"))
Next
vars("width") = e.Form.width
vars("height") = e.Form.height
e.Form.ResumeRedraw
End If
改成:(主窗口)
Dim pl As WinForm.Panel = e.Form.Controls("Panel1")
If pl.Width> 0 AndAlso pl.height > 0 Then
vars("width") = e.Form.width
vars("height") = 50
End If
Dim pl As WinForm.Panel = e.Form.Controls("Panel1")
If pl.width > 0 AndAlso pl.height > 0 Then
e.Form.StopRedraw
For Each c As Winform.Control In pl.Children
c.Left = c.Left * (pl.Width / vars("width"))
c.Top = c.Top * (pl.Height / vars("height"))
c.Width = c.Width * (pl.Width / vars("width"))
c.Height = c.Height * (pl.Height / vars("height"))
Next
vars("width") = pl.width
vars("height") = pl.height
e.Form.ResumeRedraw
End If
打开项目后窗口和控件都很正常,但是最小化后再最大化,面板中的控件就没了。
此主题相关图片如下:qq图片20170101.png

此主题相关图片如下:qq图片20170102.png

此主题相关图片如下:qq图片20170103.png

但是,从窗口设计界面点击“应用窗口”后再最小化最大化又没有问题。不知道什么原因。
此主题相关图片如下:qq图片20170104.png


此主题相关图片如下:qq图片20170105.png
[此贴子已经被作者于2017/1/12 17:29:54编辑过]