•
•
•
•
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
![]() |
•
•
Join Date: Mar 2008
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Hidden program installs .dlls with randomly generated names in random "notify" reg. (Viruses, Spyware and other Nasties)
- All Kinds of Spyware problems, Please help! (Viruses, Spyware and other Nasties)
- windows 2000 IE 6. need help to remove spyware (Viruses, Spyware and other Nasties)
- Viruses/Spam is EVERYWHERE!! HELP!! HJT Log inside PLZZ HELP (Viruses, Spyware and other Nasties)
- HiJackThis Log -- please help (Viruses, Spyware and other Nasties)
- Trojan.Downloader.BHO.Req (Viruses, Spyware and other Nasties)
- Internet Access Stopped Working (Viruses, Spyware and other Nasties)
- Still looking for help: VX2 or something like it... (Viruses, Spyware and other Nasties)
- help with hjt and vx2/urllogic (Viruses, Spyware and other Nasties)
Other Threads in the VB.NET Forum
- Previous Thread: Help with timer
- Next Thread: Thumbnail and tree view


Linear Mode