Click here to Skip to main content
13,449,902 members (52,592 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have 4 picture box's on a form and i want to retrieve images from database and provide navigations, on a combo box selection ... i have tried a lot but all my picture box's are retrieving some random images and only first picturebox is following the navigations and that too not properlyy... please help.. stucked up badlyy.... thnxx in advance..!!!

Dim con As New SqlConnection("Data Source=hp-pc;Initial Catalog=DB_RoyalProject;Integrated Security=True")
    Dim da As New SqlDataAdapter("Select * from TB_Tile_Layout_Patterns where Tile_Patterns_ID=1", con)
    Dim ds As New DataSet
    Dim dv As New DataView
    Dim c As CurrencyManager
    Public Sub fill()
        da.Fill(ds, "TB_Tile_Layout_Patterns")
        dv = New DataView(ds.Tables("TB_Tile_Layout_Patterns"))
        c = CType(Me.BindingContext(dv), CurrencyManager)
end sub

Public Sub bind()
        lbl_ptrn1.DataBindings.Add("text", dv, "Tile_Layout_Patterns")
        lbl_ptrn2.DataBindings.Add("text", dv, "Tile_Layout_Patterns")
        lbl_ptrn3.DataBindings.Add("text", dv, "Tile_Layout_Patterns")
        lbl_ptrn4.DataBindings.Add("text", dv, "Tile_Layout_Patterns")
        lbl_dmnsn1.DataBindings.Add("text", dv, "Dimension_Of_Tile1")
        lbl_dmnsn2.DataBindings.Add("text", dv, "Dimension_Of_Tile1")
        lbl_dmnsn3.DataBindings.Add("text", dv, "Dimension_Of_Tile1")
        lbl_dmnsn4.DataBindings.Add("text", dv, "Dimension_Of_Tile1")
        PictureBox1.DataBindings.Add("imagelocation", dv, "Tile_Layout_Patterns_Image")
        PictureBox2.DataBindings.Add("imagelocation", dv, "Tile_Layout_Patterns_Image")
        PictureBox3.DataBindings.Add("imagelocation", dv, "Tile_Layout_Patterns_Image")
        PictureBox4.DataBindings.Add("imagelocation", dv, "Tile_Layout_Patterns_Image")

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
 If ComboBox1.SelectedItem = "One Tile Patterns" Then
            Label4.Text = "One Tile Patterns"

            lbl_dsgn1.Visible = False
            lbl_dsgn2.Visible = False
            lbl_dsgn3.Visible = False
            lbl_dsgn4.Visible = False

            lbl_ptrn1.Visible = True
            lbl_ptrn2.Visible = True
            lbl_ptrn3.Visible = True
            lbl_ptrn4.Visible = True
            lbl_dmnsn1.Visible = True
            lbl_dmnsn2.Visible = True
            lbl_dmnsn3.Visible = True
            lbl_dmnsn4.Visible = True

            Dim cmd As New SqlCommand("Select * from TB_Tile_Layout_Patterns where Tile_Patterns_ID=1", con)
            Dim dr As SqlDataReader
            dr = cmd.ExecuteReader

            While (dr.Read)
                lbl1.Text = dr(2)
                lbl2.Text = dr(5)
                pb1.ImageLocation = dr(3)
                Exit While
            End While

            While (dr.Read)
                lbl_ptrn1.Text = dr(2)
                lbl_dmnsn1.Text = dr(5)
                PictureBox1.ImageLocation = dr(3)
                Exit While
            End While

            While (dr.Read)
                lbl_ptrn2.Text = dr(2)
                lbl_dmnsn2.Text = dr(5)
                PictureBox2.ImageLocation = dr(3)
                Exit While
            End While

            While (dr.Read)
                lbl_ptrn3.Text = dr(2)
                lbl_dmnsn3.Text = dr(5)
                PictureBox3.ImageLocation = dr(3)
                Exit While
            End While

            While (dr.Read)
                lbl_ptrn4.Text = dr(2)
                lbl_dmnsn4.Text = dr(5)
                PictureBox4.ImageLocation = dr(3)
                Exit While
            End While
        End If
    End Sub


    Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelgn.LinkClicked
        c.Position = c.Position + 1

    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelgf.LinkClicked
        While (c.Position = 0)

        End While
        If (c.Position = 0) Then
            MsgBox("First Record")
            c.Position = c.Position - 1
        End If
    End Sub

    Private Sub LinkLabel4_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelgp.LinkClicked
        If (c.Position = c.Count - 1) Then
            MsgBox("This is the last record")
            c.Position = c.Position + 1
        End If
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelgl.LinkClicked
        c.Position = c.Count - 1
    End Sub
End Class
Posted 11-Nov-12 8:50am
Updated 11-Nov-12 19:53pm
Nelek 11-Nov-12 16:00pm
please read: what have you tried?[^]
You are telling you tried a lot and it is not working, but you are not giving any usefull information to us, so it is quite difficult to help you. We can not read minds or do astral projections to see your computer to know where the error is.
Please use the "improve question" widget and add some pieces of the code that is giving you problems.
Sergey Alexandrovich Kryukov 11-Nov-12 23:28pm
Sorry, I removed your code you posted as "Solution". This is not solution, and the post should be removed. Please add the code to the body of the question using "Improve question" above.
Mustafa_9664 12-Nov-12 15:21pm
Someone please help as i desperately need it..!!!!
ryanb31 12-Nov-12 16:36pm
Nothing is random in computers so have you stepped through the code? That's the only way you'll find why it's loading a "random" image.
Kschuler 13-Nov-12 10:55am
Can you be more specific about how it is not working? What is currently happening, and what do you WANT to happen? I noticed that you didn't use any ORDER BY clauses in your SQL. If you are expecting the pictures to appear in a certain order, perhaps you should look into that.
Mustafa_9664 13-Nov-12 13:41pm
@kschuler... as i mentioned before that i have 4 picture box's and the start 4 picture's are also retrieving properly but as i start navigating it to previous, next, first or last.. all the box's starts displaying the same images right from the start..!!! help please.. in desperate need..!!! can u please correct the code for me as i am a new programmer.. please..!!!
Mustafa_9664 14-Nov-12 3:02am
Some1 Please Rep..!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180318.3 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100