Date: 14-Feb-2015
Dear Members,
I am developing a project in VB 2008 where a product image is to be displayed in a picture box when a user selects the product name from DataGridView. All the images are stored on a hard-drive. If image-path is not stored in the Database [Access-2007] for any product, a label [lblNoImage2Display] is created and displayed in the same picture-box saying ?Image not available?.
On selection of certain product for which image-path is not stored in the DataBase, the label is displayed in the picture-box perfectly. But when I move to next product for which image-path is available, the picture-box displays the relevant image along with the label. I have tried setting the VISIBLE property to false of the lblNoImage but it continues to display. The picture-box [pbxProduct] is a design-time control and created on Win-form. The Label is created at Runtime.
I am not able to figure out what?s wrong with the code. I am re-producing the code below:
Dim lblNoImage2Display As New Label
With lblNoImage2Display
.Text = "Nothing to display"
.Location = New Drawing.Point(130, 20)
.AutoSize = True
.Font = New Font("Cambria", 14, FontStyle.Regular, GraphicsUnit.Point)
End With
pbxCard.Controls.Add(lblNoImage2Display)
Dim strFileName As String = dgvList.CurrentRow.Cells.Item("pImagePath").Value.ToString
pbxCard.Image = Nothing
If strFileName.Length > 0 Then
lblNoImage2Display.Visible = False
lblNoImage2Display.SendToBack()
With pbxCard
.Refresh()
.SizeMode = PictureBoxSizeMode.StretchImage
.Image = System.Drawing.Image.FromFile(strFileName)
End With
Else
lblNoImage2Display.Visible = True
End If
Any suggestions/ modifications are awaited to achieve desired result.
Thanks and Regards,
Dear Members,
I am developing a project in VB 2008 where a product image is to be displayed in a picture box when a user selects the product name from DataGridView. All the images are stored on a hard-drive. If image-path is not stored in the Database [Access-2007] for any product, a label [lblNoImage2Display] is created and displayed in the same picture-box saying ?Image not available?.
On selection of certain product for which image-path is not stored in the DataBase, the label is displayed in the picture-box perfectly. But when I move to next product for which image-path is available, the picture-box displays the relevant image along with the label. I have tried setting the VISIBLE property to false of the lblNoImage but it continues to display. The picture-box [pbxProduct] is a design-time control and created on Win-form. The Label is created at Runtime.
I am not able to figure out what?s wrong with the code. I am re-producing the code below:
Dim lblNoImage2Display As New Label
With lblNoImage2Display
.Text = "Nothing to display"
.Location = New Drawing.Point(130, 20)
.AutoSize = True
.Font = New Font("Cambria", 14, FontStyle.Regular, GraphicsUnit.Point)
End With
pbxCard.Controls.Add(lblNoImage2Display)
Dim strFileName As String = dgvList.CurrentRow.Cells.Item("pImagePath").Value.ToString
pbxCard.Image = Nothing
If strFileName.Length > 0 Then
lblNoImage2Display.Visible = False
lblNoImage2Display.SendToBack()
With pbxCard
.Refresh()
.SizeMode = PictureBoxSizeMode.StretchImage
.Image = System.Drawing.Image.FromFile(strFileName)
End With
Else
lblNoImage2Display.Visible = True
End If
Any suggestions/ modifications are awaited to achieve desired result.
Thanks and Regards,