vb中 怎么样给picturebox加滚动条?
2个回答
展开全部
你是不是要用滚动条调整图片的显示?
给你个程序 或许对你有帮助
给窗口添加个PICTUREBOX 控件 吧一个IMAGE控件加到PICTRUEBOX里 再加一个VSCROLL 和一个HSCROLL
分别放在PICTUREBOX 的纵向喝水平方向
加如下代码就可以
Private Sub Form_Resize()
On Error Resume Next
w = Form1.ScaleWidth - VScroll1.Width
h = Form1.ScaleHeight - HScroll1.Height
VScroll1.Move w, 0, VScroll1.Width, h
HScroll1.Move 0, h, w
With Picture1
.Move 0, 0, w, h
VScroll1.Min = 0
VScroll1.Max = Image1.Height - .Height
HScroll1.Min = 0
HScroll1.Max = Image1.Width - .Width
End With
If Image1.Width < Picture1.Width Then
HScroll1.Visible = False
Else
HScroll1.Visible = True
HScroll1.Min = 0
HScroll1.Max = Image1.Width - Picture1.Width
End If
If Image1.Height < Picture1.Height Then
VScroll1.Visible = False
Else
VScroll1.Visible = True
VScroll1.Min = 0
VScroll1.Max = Image1.Height - Picture1.Height
End If
End Sub
Private Sub HScroll1_Change()
Image1.Left = -HScroll1.Value
End Sub
Private Sub HScroll1_Scroll()
Image1.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Image1.Top = -VScroll1.Value
End Sub
Private Sub VScroll1_Scroll()
Image1.Top = -VScroll1.Value
End Sub
给你个程序 或许对你有帮助
给窗口添加个PICTUREBOX 控件 吧一个IMAGE控件加到PICTRUEBOX里 再加一个VSCROLL 和一个HSCROLL
分别放在PICTUREBOX 的纵向喝水平方向
加如下代码就可以
Private Sub Form_Resize()
On Error Resume Next
w = Form1.ScaleWidth - VScroll1.Width
h = Form1.ScaleHeight - HScroll1.Height
VScroll1.Move w, 0, VScroll1.Width, h
HScroll1.Move 0, h, w
With Picture1
.Move 0, 0, w, h
VScroll1.Min = 0
VScroll1.Max = Image1.Height - .Height
HScroll1.Min = 0
HScroll1.Max = Image1.Width - .Width
End With
If Image1.Width < Picture1.Width Then
HScroll1.Visible = False
Else
HScroll1.Visible = True
HScroll1.Min = 0
HScroll1.Max = Image1.Width - Picture1.Width
End If
If Image1.Height < Picture1.Height Then
VScroll1.Visible = False
Else
VScroll1.Visible = True
VScroll1.Min = 0
VScroll1.Max = Image1.Height - Picture1.Height
End If
End Sub
Private Sub HScroll1_Change()
Image1.Left = -HScroll1.Value
End Sub
Private Sub HScroll1_Scroll()
Image1.Left = -HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Image1.Top = -VScroll1.Value
End Sub
Private Sub VScroll1_Scroll()
Image1.Top = -VScroll1.Value
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询