Click here to Skip to main content

Mustafa_9664 asked:

Open original thread
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.Clear()
        lbl_ptrn2.DataBindings.Clear()
        lbl_ptrn3.DataBindings.Clear()
        lbl_ptrn4.DataBindings.Clear()
        lbl_dmnsn1.DataBindings.Clear()
        lbl_dmnsn2.DataBindings.Clear()
        lbl_dmnsn3.DataBindings.Clear()
        lbl_dmnsn4.DataBindings.Clear()
        PictureBox1.DataBindings.Clear()
        PictureBox2.DataBindings.Clear()
        PictureBox3.DataBindings.Clear()
        PictureBox4.DataBindings.Clear()
 
        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
 

            con.Open()
            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
            con.Close()
        End If
    End Sub
 

'navigations..

    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")
        Else
            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")
        Else
            c.Position = c.Position + 1
        End If
        bind()
    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
        bind()
    End Sub
End Class
Tags: VB.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
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