在Windows窗体中显示图片 [英] Show a picture in windows forms

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

问题描述

我有一个gridviw,其中包含一个pdf和图像文件(来自我的驱动器),现在,我想在Windows窗体中显示以网格格式选择的文件,但

为pdf文件:表格保留灰色颜色

图片文件:我看到错误icone



这是我的图像文件代码



I have a gridviw which contain an pdf and image file (from my drive) , Now , i want To show the file selected in grid in windows forms but
for pdf file : the forms stay gray color
for image file : i see the error icone

Here is my code for image file

Dim i As Integer = gridfile.CurrentRow.Index
    Dim ext As String = gridfile.Item(0, i).Value
    Dim tab() As String = ext.Split(".")
    If (tab(1) = "jpg") Then 
        see_image.image.ImageLocation = ext
    ElseIf (tab(1) = "png") Then
       see_image.image.ImageLocation = ext
    ElseIf (tab(1) = "gif") Then
        see_image.image.ImageLocation = ext





see_image是表格名称

图片是图片框名称

i是gridview中选择的行的索引

ext是gridview中选择的行的值



gridview中存在的所有文件都是从Go导入的ogle Drive(使用其他方法)



我尝试过:



我创建了一个以另一种形式显示文件的方法



see_image is forms name
image is picturebox name
i is index of line selected in gridview
ext is value of line selected in gridview

All files exist in gridview were imported from Google Drive (with another method)

What I have tried:

I create a method to show file in another forms

推荐答案

首先使用调试器找出你在 ext中的确切内容运行代码时。在该行上设置一个断点:

Start by using the debugger to find out what exactly you have in ext when you run your code. Put a breakpoint on the line:
Dim tab() As String = ext.Split(".")

当调试器点击它时,查看ext的内容。使用Windows资源管理器检查文件夹,文件和驱动器是否都可访问,并且它是有效的路径名。



如果是这样,请执行调试器,然后查看在完成拆分后,您完全可以在选项卡中获得。注意标签(1) - 它是否与您的字符串完全匹配,请记住字符串 区分大小写,所以JPG与jpg等不一样。



对不起,但我们不能为你做任何事 - 给你时间学习一种新的(非常非常有用的)技能:调试!

And when the debugger hits it, look at the content of ext. Check with Windows Explorer that the folder, file, and drive are all accessible, and that it is a valid path name.

If so, step the debugger, and look at exactly what you get in in tab after the Split is done. Pay attention to tab(1) - does it exactly match your strings, bearing in mind that strings are case sensitive, so "JPG" it not the same as "jpg" and so forth.

Sorry, but we can't do any of that for you - time for you to learn a new (and very, very useful) skill: debugging!


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

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