Click here to Skip to main content
16,020,261 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 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
Posted
Updated 14-Aug-17 23:06pm
v2
Comments
Richard MacCutchan 15-Aug-17 4:29am    
A PDF file is not an image.
Member 8587273 15-Aug-17 4:33am    
pdf file in another method , my code here for image file , i used pdf file in my subject for explication !!!!!!!!!!
Richard MacCutchan 15-Aug-17 5:09am    
Well please do not. Explain exactly what the problem is, and show the exact code.

1 solution

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:
VB
Dim tab() As String = ext.Split(".")
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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900