i want to generate thumbnails retrieving images from data base
for this purpose i m using sql server data base and the name of SQL Connection is SqlConn.
i m using List View for Thumbnail purpose.
i m using tree view for creating Albums and Photos in data base.
i m using tree root as Album and its corresponding nodes as photos
now i have tried to write code for this purpose
i m using a function ShowThumbnail, it is used for to generate thumbnail
and i m calling it in AfterSelect event of Tree View as ShowThumbnail(item)
it is giving no syntax erros but still my application is not generating thumbnail
my ShowPhoto method is as follow now
Private Sub ShowThumbnail(ByVal item As TreeItem)
Try
' Create a command to select the selected photo
Dim cmd As SqlCommand
cmd.CommandText = "Photo"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = sqlConn
sqlConn.Open()
Dim sqlPhotoAlbum As SqlDataReader
cmd.ExecuteReader()
' Set the description
lblDesc.Text = item.Desc
' Get bytes return from stored proc
Dim imgList As New ImageList()
While (sqlPhotoAlbum.Read())
Dim node As TreeNode = Nothing
'Populate all images
Dim data As Byte() = CType(sqlPhotoAlbum("Photo"), Byte())
Dim ms As New System.IO.MemoryStream(data, 0, data.Length)
Dim photo As Image = Image.FromStream(ms) ''
imgList.Images.Add(sqlPhotoAlbum("PhotoName").ToString(), photo)
treeAlbum.ImageList = imgList
End While
' Draw photo to scale of picturebox
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub
and tree view's AfterSelect event is as followed
Private Sub treeAlbum_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeAlbum.AfterSelect
Try
' Disable edit controls if we were in edit mode
If True = btnUpdate.Visible Then
btnUpdate.Visible = False
txtDesc.Visible = False
lblDesc.Visible = True
End If
' Retrieve the item info for this node
Dim item As TreeItem = DirectCast(e.Node.Tag, TreeItem)
' If the selected item is an album...
If ItemType.Album = item.Type Then
lblDesc.Text = item.Desc
' Set the description
ShowThumbnail(item)
' Clear the image
Return
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
plz tell me what I should do now to generate thumbnail
plz see my both the above code snipts
what changes I should make now in showphoto method and AfterSelect event of treeView so that I can generate thumbnail view of images
and i m also sending u my whole code for this purpose.
thanks