当窗体变大或变小时,窗体上的控件也随着变大或变小!该怎么做???

wangchong 2003-08-19 11:58:59
在VB6中,我是在RESIDE事件中谢代码,VB.NET中怎么办!!!!
...全文
52 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjfzju 2003-08-20
  • 打赏
  • 举报
回复
设置一下Anchor,Dock属性
可以查找帮助了解这两个属性
ganenpingsohucom 2003-08-20
  • 打赏
  • 举报
回复
可以在resize事件中用
controll.scale(比例)
比例可以自己根据resize的幅度自己定义


beckham1122 2003-08-20
  • 打赏
  • 举报
回复
用控件的anchor 和 dock属性啊。它可以定位该控件在整个窗体中的位置
xixigongzhu 2003-08-20
  • 打赏
  • 举报
回复
不好意思,忘了是VB了:
Private Sub HelpDemo_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
If (Me.Width >= 80) Then
Me.ShowHelp.Width = (Me.Width - 24) / 2
Me.helpProvider.Width = (Me.Width - 24) / 2
End If
Me.ShowHelp.Height = Me.Height - 16
Me.helpProvider.Height = Me.Height - 16
Me.helpProvider.Location = New Point(Me.ShowHelp.Width + 16, Me.helpProvider.Location.Y)
Dim w As Integer = 0, h As Integer = 0
If (Me.ShowHelp.Width >= Me.Panel1.Width) Then
w = (Me.ShowHelp.Width - Me.Panel1.Width) / 2
End If
If (Me.ShowHelp.Height >= Me.Panel1.Height + 80) Then
h = 48
ElseIf (Me.ShowHelp.Height >= Me.Panel1.Height + 12) Then
h = (Me.ShowHelp.Height - Me.Panel1.Height) / 2
Else
h = 12
End If
Me.Panel1.Location = New Point(w, h)
If (Me.helpProvider.Width > 40) Then
Me.Label2.Width = Me.helpProvider.Width - 40
End If
If (Me.helpProvider.Width >= Me.GroupBox1.Width) Then
w = (Me.helpProvider.Width - Me.GroupBox1.Width) / 2
Else
w = 0
End If
Me.GroupBox1.Location = New Point(w, 64 + Me.Label2.Height)
Me.GroupBox2.Location = New Point(w, 160 + Me.Label2.Height)
Me.GroupBox3.Location = New Point(w, 280 + Me.Label2.Height)
End Sub
xixigongzhu 2003-08-20
  • 打赏
  • 举报
回复
类似于:
初始化:
this.SizeChanged += new System.EventHandler(this.HelpDemo_SizeChanged);
事件处理:
private void HelpDemo_SizeChanged(object sender, System.EventArgs e)
{
if(this.Width >= 80)
{
this.ShowHelp.Width = (this.Width - 24)/2;
this.helpProvider.Width = (this.Width - 24)/2;
}
this.ShowHelp.Height = this.Height - 16;
this.helpProvider.Height = this.Height - 16;
this.helpProvider.Location = new Point(this.ShowHelp.Width + 16,this.helpProvider.Location.Y);
int w = 0,h = 0;
if(this.ShowHelp.Width >= this.panel1.Width)
w = (this.ShowHelp.Width - this.panel1.Width)/2;
if(this.ShowHelp.Height >= this.panel1.Height + 80)
h = 48;
else if(this.ShowHelp.Height >= this.panel1.Height +12)
h = (this.ShowHelp.Height - this.panel1.Height)/2;
else h = 12;
this.panel1.Location = new Point(w,h);
if(this.helpProvider.Width > 40)
this.label2.Width = this.helpProvider.Width - 40;
if(this.helpProvider.Width >= this.groupBox1.Width)
w = (this.helpProvider.Width - this.groupBox1.Width)/2;
else w = 0;
this.groupBox1.Location = new Point(w,64 + this.label2.Height);
this.groupBox2.Location = new Point(w,160 + this.label2.Height);
this.groupBox3.Location = new Point(w,280 + this.label2.Height);
}
hpfeng 2003-08-19
  • 打赏
  • 举报
回复
anchor 设置:top ,left,right,bottom
chenlm 2003-08-19
  • 打赏
  • 举报
回复
不用写代码,看看控件的anchor 和 dock属性

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧