NET将输入图像添加到列表视图

NET将输入图像添加到列表视图

本文介绍了如何在运行时使用VB.NET将输入图像添加到列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从用户那里输入了5张图片,并将其显示在相册中,现在我也希望这些图片也显示在列表视图中.如何在列表视图中同时传递它们.我尝试了以下代码,但它在相册中显示的图像不在listview中.

I have taken input of 5 images from user and showed it in photogallery now I want these images in list view too. How should I pass them in list view simultaneously. I tried the below code but it shows images in photogallery not in listview.

Private Sub BrowseMultipleFilesButton_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles BrowseMultipleFilesButton.Click
    Dim OpenFileDialog1 As New OpenFileDialog
    OpenFileDialog1.Filter =
    "Images (*.BMP;*.JPG;*.GIF,*.PNG,*.TIFF)|*.BMP;*.JPG;*.GIF;*.PNG;*.TIFF|" +
    "All files (*.*)|*.*"
    OpenFileDialog1.Multiselect = True
    Dim index As New Integer
    OpenFileDialog1.Title = "Select Photos"
    If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
    If OpenFileDialog1.FileNames.Length > 5 Then
    MessageBox.Show("Please select no more than 5 files")
    Exit Sub
    End If
    If OpenFileDialog1.FileNames.Length < 5 Then
    MessageBox.Show("Please select 5 files")
    Exit Sub
    End If
    For Each file As String In OpenFileDialog1.FileNames
    Dim imageControl As New PictureBox()
    imageControl.Height = 100
    imageControl.Width = 100
    Dim myCallback As New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
    Dim myBitmap As New Bitmap(file)
    Dim myThumbnail As Image = myBitmap.GetThumbnailImage(96, 96, myCallback, IntPtr.Zero)
    imageControl.Image = myThumbnail
    PhotoGallary.Controls.Add(imageControl)
    Dim imageListLarge As New ImageList()
    imageListLarge.Images.Add(myBitmap)
    ListView_images.LargeImageList = imageListLarge
    Me.Controls.Add(ListView_images)
    Next
    btn_Save.Enabled = True
    BrowseMultipleFilesButton.Enabled = False
    End If
    End Sub

推荐答案


这篇关于如何在运行时使用VB.NET将输入图像添加到列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 06:05