解决picture控件大小问题
程序中使用picturebox控件绘制直方图,但随着数据量增大,直方图的数量很多难以辨别
如何固定直方图单个大小,当数据增加后超过picturebox长度后,显示滑动条,类似图片超过控件后显示滑动条,而图片本身大小不变
[解决办法]
下面代码你可以参考 再自行改进
Picture2为你固定的PictureBox, Picture1是你的直方图,宽高度在你添加新图时,原图尺寸加上新添加的尺寸
"如何固定直方图单个大小,当数据增加后超过picturebox长度后,显示滑动条"
可以用这方法
VScroll1.Visible = Picture1.Height > Picture2.Height
添加 HScroll1 VScroll1 Picture1 Picture2
'***********************************************
Option Explicit
Private Sub Form_Load()
On Error Resume Next
VScroll1.Width = 350: HScroll1.Height = 350
Picture2.Move 225, 915: Set Picture1.Container = Picture2: Picture1.Move 0, 0
End Sub
Private Sub Form_Resize()
VScroll1.Max = (Picture1.Height - Picture2.ScaleHeight)
VScroll1.Move Me.Width - VScroll1.Width, Picture2.Top, VScroll1.Width, Picture2.Height
VScroll1.Visible = Picture1.Height > Picture2.Height
HScroll1.Max = (Picture1.Width - Picture2.ScaleWidth)
HScroll1.Move 0, Me.Height - HScroll1.Height, Picture2.Width, HScroll1.Height
HScroll1.Visible = Picture1.Width > Picture2.Width
HScroll1.Value = 0: VScroll1.Value = 0
VScroll1.LargeChange = Picture2.ScaleHeight
HScroll1.LargeChange = Picture2.ScaleWidth
VScroll1.SmallChange = 20: VScroll1.Min = 0
HScroll1.SmallChange = 20: HScroll1.Min = 0
End Sub
Private Sub hscroll1_Change()
Picture1.Left = -CLng(HScroll1.Value)
End Sub
Private Sub hscroll1_Scroll()
Picture1.Left = -CLng(HScroll1.Value)
End Sub
Private Sub vscroll1_Change()
Picture1.Top = -CLng(VScroll1.Value)
End Sub
Private Sub vscroll1_Scroll()
Picture1.Top = -CLng(VScroll1.Value)
End Sub