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
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