User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 427,378 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,042 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 882 | Replies: 0
Reply
Join Date: Mar 2008
Posts: 7
Reputation: aamir55 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
aamir55 aamir55 is offline Offline
Newbie Poster

how to get thumbnail view using tree view

  #1  
Mar 30th, 2008
i m working on a small application
its main function is to create a album and then add photos in the album.
i m using tree view for creating album and photos
i m using tree root as album and nodes as photos.
i have to also show photos when i click on photo name
i m using function showphoto for this purpose
i m using sql server to store picture in database and then retrieve from it
but i also want to generate thumbnail when i click on album name and all the images should be displayed as thumbnail on picbox
is there any control for this purpose or how i can do that?
i m also sending this application plz help me
Private Sub ShowPhoto(ByVal item As TreeItem)
Try
' Create a command to select the selected photo
Dim strCmd As String = [String].Format("SELECT photo FROM Photos WHERE id = {0}", item.Id)
Dim cmd As New SqlCommand(strCmd, sqlConn)

' Set the description
lblDesc.Text = item.Desc

' Get bytes return from stored proc
Dim b As Byte() = CByte(cmd.ExecuteScalar())
If b.Length > 0 Then
' Open a stream for the image and write the bytes into it
Dim stream As New System.IO.MemoryStream(b, True)
stream.Write(b, 0, b.Length)

' Draw photo to scale of picturebox
DrawToScale(New Bitmap(stream))

' Close the stream and delete the temp file
stream.Close()
End If
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub

if i use above function to show photo
error comes on this line
Dim b As Byte() = CByte(cmd.ExecuteScalar())
and erroe says"Error 1 Value of type 'Byte' cannot be converted to '1-dimensional array of Byte'"
if i remove Cbyte from above line then application runs well but when i click on photo name then picture doesn't appear in picturebox.
and i m using showphoto function in below code snipts

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
PictureBox.Image = Nothing
' Clear the image
Return
End If

' ...otherwise it is a photo
ShowPhoto(item)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Attached Files
File Type: zip e.zip (79.9 KB, 6 views)
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 4:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC