[VB.NET]如何通过FileListBox在PictureBox显示图片!!!!

前端之家收集整理的这篇文章主要介绍了[VB.NET]如何通过FileListBox在PictureBox显示图片!!!!前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何通过FileListBox在PictureBox显示图片!!!! 请问,我已经在FileListBox现在了图片文件列表,应该怎么做在单击其中一个图片文件的时候,在PictureBox立即显示出来呢?? 还有应该怎么做才能 通过 “上一个” “下一个”的按钮来显示filelistBox中的图片呢!!! 麻烦大家了!!!! __________________________________________________________________________ FileListBox是什么控件? __________________________________________________________________________ 在单击的事件中写入 Me.PictureBox1.Image = Image.FromFile( "含路径文件名 ") 就行了。 __________________________________________________________________________ 这个“含路径文件名”是通过点击filelistBox下的图片文件获得的!!要怎么获得呢??? __________________________________________________________________________ 我没用过FileListBox这个控件,工具箱里没有噢。 __________________________________________________________________________ 不过您既然能把文件加载到这个控件中那么应该可以用某种形式来保存他们的文件名吧,实在不行就定义一个字符串数组,把文件名保存在里面;用FileListBox的Index值来匹配数组的Index,也可以的。 __________________________________________________________________________ FileListBox是通过在工具箱中添加/删除项 来加入的!是用来显示目录下的文件~~ 我用 Me.PictureBox1.Image = Image.FromFile( "FileListBox1.Items.Strings[FileListBox1.Itemindex] ") 还是不行 郁闷死了~~大家帮帮忙啊!! __________________________________________________________________________ 现在的问题是如何获得FileListBox这个控件下的路径和文件名,然后通过单击在PictureBox显示!!! __________________________________________________________________________ 明明只有我一个在这儿么…… -_-||| __________________________________________________________________________ 晕掉了~~~没有知道么~~55555 __________________________________________________________________________ Public Class Form1 Private Sub Form1_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load Me.FileListBox1.Path = "D:/My Documents/My Pictures " End Sub Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As Object,ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged Me.PictureBox1.Image = Image.FromFile(Me.FileListBox1.Path & "/ " & Me.FileListBox1.Items(Me.FileListBox1.SelectedIndex).ToString) End Sub End Class __________________________________________________________________________ Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As Object,ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged Me.PictureBox1.Image = Image.FromFile(Me.FileListBox1.Path & "/ " & Me.FileListBox1.Items(Me.FileListBox1.SelectedIndex).ToString) End Sub 用这个可以啦,呵呵。 __________________________________________________________________________ -_-|||,这样写好一点。 Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As Object,ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged Me.PictureBox1.Image = Image.FromFile(Me.FileListBox1.Path & "/ " & Me.FileListBox1.SelectedItem.ToString) End Sub __________________________________________________________________________ 我刚才这么做 Me.PictureBox1.Image = Image.FromFile(FileListBox1.Path & " / " & FileListBox1.FileName) 原来第二个忘记用select~~~~~郁闷~~~~~ 谢谢你啊!!!!呵呵!!分给你了!!!! __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/263813.html

猜你在找的VB相关文章