我在窗体下部放了了两个按钮、一个picture控件、一个label控件,运行一下下面的程序:
Private Sub Form_Load()
Picture1.Move 0, 0
Picture1.Height = (Label1(0).Height + 5) * 10 + 3
Picture1.Width = (Label1(0).Width + 5) * 10 + 3
Me.Height = Picture1.Height + 900
Me.Width = Picture1.Width + 80
Label1(0).Visible = False
For n = 1 To 100
i = (n - 1) \ 10: j = (n - 1) Mod 10: Load Label1(n)
With Label1(n)
.Left = 5 + j * Label1(0).Width
.Top = 5 + i + Label1(0).Height
.Visible = True
.Caption = n
End With
Next
End Sub
我本来想让按钮正好放在picture控件下的,现在因为窗体大小的改变它们的位置就不对了!得拉大窗体才看到了那两个按钮家伙~如何写程序让它们随窗体的变小也能放在原有的位置上呢?
Private Sub Form_Load()
Picture1.Move 0, 0
Picture1.Height = (Label1(0).Height + 5) * 10 + 3
Picture1.Width = (Label1(0).Width + 5) * 10 + 3
Me.Height = Picture1.Height + 900
Me.Width = Picture1.Width + 80
Label1(0).Visible = False
For n = 1 To 100
i = (n - 1) \ 10: j = (n - 1) Mod 10: Load Label1(n)
With Label1(n)
.Left = 5 + j * Label1(0).Width
.Top = 5 + i + Label1(0).Height
.Visible = True
.Caption = n
End With
Next
End Sub
我本来想让按钮正好放在picture控件下的,现在因为窗体大小的改变它们的位置就不对了!得拉大窗体才看到了那两个按钮家伙~如何写程序让它们随窗体的变小也能放在原有的位置上呢?
解决方案 »
- vb6.0 datagrid checkbox
- vb怎么获得指定目录下所有子目录的目录名??
- 谁能给个 DES 的vb源码研究研究!
- 如何对DataGrid中的每一单元格更新前进行字段校验?
- 你好 打扰你一下 广东的朋友
- 如何控制打印的页面边框,再不能打印的时候给个提示?谢谢,很急
- 请教高手,如何在通用对话框commondialog中打开文件?谢谢!
- 各位大哥,帮忙了!小第近日编了个OCX,定义了一个属性是数组,即我想把一个二维数组值传递给该属性,怎么搞啊?
- 麻烦写过vb帮助文档的兄弟送一份.rtf格式的word文档给我.
- 请问怎样以binary方式读取文件的一部分数据?谢了
- 我一分没有了。不好意思。在access中那里可以写SQL语句。我找不到。谢谢谢谢!!!! (lbsoftware )
- 怎样才能让vb+sql编的数据库程序在没有装sql的计算机上运行?
Private Sub Form_Resize()
Command1.Left = Form1.Width - Command1.Width - 500
Command1.Top = Form1.Top + Command1.Height + 500End Sub
'Command1.Left = Form1.Width - Command1.Width - 500
Command1.Top = picture1.Top + picture1.Height + 500End Sub
Dim x As Integer
x = 100
Command1.Left = x
Command1.Top = Picture1.Top + Picture1.Height + 10
Command2.Left = Command1.Left + Command1.Width + 100
Command2.Top = Command1.Top
End Sub还有如果一点要注意,对于容易控件注意ScaleWidth,Width和ScaleHeight,Height的区别
比如Private Sub Form_Resize()Picture1.Move 0, 0, Form1.ScaleWidth / 2, Form1.ScaleHeight / 2
Command1.Left = Form1.ScaleWidth - Picture1.Width - 20
Command2.Left = Form1.Width - Picture1.Width - 20
Command2.Top = Command1.Top + Command1.Height
End Sub
Picture1.Move 10, 10, ScaleWidth - 10, ScaleHeight - 500
Command1.Move ScaleWidth - Command1.Width - 60, Picture1.Top + Picture1.Height + 100
End Sub
然后在resize事件中重画一下不就行了
自己算一下位置咯