窗口中有picturebox控件,需要获得服务器上图片的宽与高,决定图片在控件中的缩放方式。如何获得该图片的宽与高?谢谢!
Dim pb As WinForm.PictureBox = e.form.controls("PictureBox1")
pb.FTPclient = ftp1 '服务器图片
pb.ImageFile = t5 & t1
Dim img As Image = GetImage(t5 & t1)
If img.Height < pb.Height AndAlso img.Width < pb.Width Then
pb.SizeMode = ImageSizeMode.CenterImage
Else
pb.SizeMode = ImageSizeMode.Zoom
End If
运行提示:未将对象引用设置到对象的实例。
代码“dim img as image 。。。”前的部分运行正常。
代码错误应该在:Dim img As Image = GetImage(t5 & t1)
[此贴子已经被作者于2021/3/15 9:54:34编辑过]