How to paste image into picturebox from clipboard with VB.Net
How to paste image into picturebox from clipboard with VB.Net If you wish to paste an image into a picturebox from clipboard for your VB.Net project, this is what to do: 1. Add a picturebox to your form. 2. Add a button and copy paste the code below. Private Sub btnPastePic_Click(sender As Object, e As EventArgs) Handles btnPastePic.Click 'If My.Computer.Clipboard.ContainsImage Then ' PictureBox1.Image = My.Computer.Clipboard.GetImage 'End If Dim idata As IDataObject = Clipboard.GetDataObject() If idata.GetDataPresent("System.Drawing.Bitmap") Then Dim imgObject As Object = idata.GetData("System.Drawing.Bitmap") If imgObject IsNot Nothing Then Dim img As Image = TryCast(imgObject, Image) If img IsNot Nothing Then PictureBox1.Image = img End If End If End If
Comments
Post a Comment