C# Windows Forms - How to programmatically set image preview for file folder (VSTO 2010) -


windows forms - vsto - outlook

background - creating digital archive add-in office user can search database client (whom document belongs to) , save file appropriate folder(s) based on nature of file. far working word planned using outlook has more consider (attachments, message body, etc.).

i have got working far attachments saved temporary folder (which emptied each time windows form closes) ready sorted , can obtain information sender/subject/email body. list of attachments set out checkedlistbox

current problem - when user looking archive attachment (a lot of documents/scanned documents come up), images confusing may necessary or entirely unimportant wish preview images.

i trying on event of

private void chkattachments_selectedvaluechanged(object sender, eventargs e) 

the image shows in picattachpreview (picturebox) preview of file. taking image tempfolder (@"c:\temp\digitalarchive").

i understand wrong trying set source image shown on screen on selectedvaluechanged event.

my [incorrect] code -

if(chkattachments.text.contains(".jpg"))         {             var selectedimage = chkattachments.selectedvalue.tostring();             picattachpreview.image = tempfolder + @"\" + selectedimage; //(a)         } 

the (a) line issue , although understand why, don't know how resolve it. filepath constructed tempfolder , selectedimage (e.g. scanneddoc.jpg) file path type string picattachpreview system.drawing.image assume looking @ wrong property of picattachpreview set source of image.

any or guidance immensely appreciated. thank you.

(also if know of way can set same nature of preview documents/pdf immensely grateful)

edit although link solves part of problem, there issue chkattachments.selectedvalue.tostring() answered below. (if can advise me on site etiquette situation. delete question or leave answer found people can find solution same problem in future? thank you)

after playing around, found problem (chkattachment.text works whereas .selectedvalue.tostring() not.

also issue string image format resolved prefixing path image.fromfile(

so correct way of changing image upon selection is:

if(chkattachments.text.contains(".jpg"))         {             var selectedimage = chkattachments.text;             picattachpreview.image = image.fromfile(tempfolder + @"\" + selectedimage);         } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -