在Windows窗体中调整图片框的大小并移动它 [英] Resize and Move the picture Box in windows forms

查看:141
本文介绍了在Windows窗体中调整图片框的大小并移动它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在窗体中调整图片框的大小,并在窗体中将其移动到窗体中并拖动它,有人可以帮助我在互联网上找不到这两种方法之一. div class ="h2_lin">解决方案

下面提供的内容显示了如何调整图片框的大小

Private MyImage As Bitmap
Public Sub ShowMyImage(fileToDisplay As String, xSize As Integer, _
                        ySize As Integer)
    '' Sets up an image object to be displayed.
    If (MyImage IsNot Nothing) Then
         MyImage.Dispose()
    End If

    '' Stretches the image to fit the pictureBox. 
    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    MyImage = New Bitmap(fileToDisplay)
    pictureBox1.ClientSize = New Size(xSize, ySize)
    pictureBox1.Image = CType(MyImage, Image)
 End Sub 


I am trying to resize a picturebox within the form and also move it around the form within the form and drag it around, can anyone please help I can''t find how to do either of those 2 on the Internet.

解决方案

Below provided shows how you can re-size picture Box

Private MyImage As Bitmap
Public Sub ShowMyImage(fileToDisplay As String, xSize As Integer, _
                        ySize As Integer)
    '' Sets up an image object to be displayed.
    If (MyImage IsNot Nothing) Then
         MyImage.Dispose()
    End If

    '' Stretches the image to fit the pictureBox. 
    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    MyImage = New Bitmap(fileToDisplay)
    pictureBox1.ClientSize = New Size(xSize, ySize)
    pictureBox1.Image = CType(MyImage, Image)
 End Sub 


这篇关于在Windows窗体中调整图片框的大小并移动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆