Visual Basic 2005图像查看器 [英] Visual Basic 2005 Image Viewer

查看:98
本文介绍了Visual Basic 2005图像查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有文件列表框

当我单击图片(无论扩展名是什么")时,我需要在图片框中查看它,这是我的代码:

So i have filelistbox

when i click the picture("whatever the extension is") i need to view it in picturebox here is my codes:

Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged

  Me.PictureBox2.ImageLocation = Application.StartupPath & "\" & FileListBox1.SelectedItem.ToString & "*.jpg; *.gif; *.png";

End Sub



该图像将不会显示...



the image wont appear...

推荐答案

这是因为您可能无法拥有以"*.jpg; *.gif; *.png"结尾的文件名. :-)

顺便说一句,使用string.Format代替&".多重连接是不好的,因为字符串是immutable.每个串联都会导致创建一个全新的字符串并将操作数复制到其中.




This is because you cannot possibly have a file name ending with "*.jpg; *.gif; *.png". :-)

By the way, use string.Format instead of ''&''. Multiple concatenation is bad because strings are immutable; each concatenation causes creation of a brand new string and copy operands into it.


Something like

Me.PictureBox2.ImageLocation = string.Format(
    "{0}{1}{2}",
    Application.StartupPath,
    System.IO.Path.DirectorySeparatorChar,
    FileListBox1.SelectedItem.ToString);


请参阅 http://msdn.microsoft.com/en-us/library/system.string.aspx [^ ] .
[END EDIT]

—SA


See http://msdn.microsoft.com/en-us/library/system.string.aspx[^].
[END EDIT]

—SA


这篇关于Visual Basic 2005图像查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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