Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hello Alan, thanks for your patients.

I have a number of controls that produce the file name that is displayed in the label (lblCurrentFileName)
I have a groupbox (gbFileToPreview) that produces the thumbnail of the file name.
When the code is run it produces the correct CurrentFileName image in the thumbnail.
I realise that in the lblCurrentFileName_TextChanged event I have to put some code but I have tried a dozen different times and just keep getting errors.
The code I have looks like this:
-------------------------------------------------------------------------------------
Private Sub GetThumbnail(ByVal e As PaintEventArgs)
Dim UseThis As String = lblCurrentFileName.Text
Dim callback As New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
Dim image As Image = New Bitmap("C:\DIMS\Steve's Scanned Drawings\" + UseThis)
Dim pThumbnail As Image = image.GetThumbnailImage(200, 200, callback, New IntPtr())
e.Graphics.DrawImage(pThumbnail, 20, 20, pThumbnail.Width, pThumbnail.Height)
End Sub
-------------------------------------------------------------------------------------
Public Function ThumbnailCallback() As Boolean
Return True
End Function
-------------------------------------------------------------------------------------
Private Sub lblCurrentFileName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblCurrentFileName.TextChanged
'GetThumbnail(e)... have tried this and creates an exception error
'Call gbFileToPreview_Paint(sender,e)... same thing an error
End Sub
-------------------------------------------------------------------------------------
Private Sub gbFileToPreview_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles gbFileToPreview.Paint
GetThumbnail(e)
End Sub
Do you have any suggestions what code I can use in the lblCurrentFileName_TextChanged event to re-paint the thumbnail with the new current file name...?
Thanks again for your patients,
Stephen
Posted
Updated 24-Mar-11 15:05pm
v2

1 solution

Help me a little so I can help you... At what point are you trying to repaint the groupbox? Are you using the label's TextChanged event? And, where do you get the file names? Are you using a OpenFileDialog?

If you'll post some code in your reply you'll increase your chances of getting help. :-)
 
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