I'm currently working on a program that automaticly adds pictureboxes whenever you add an entree to a database (access).
I got that working, but Now I'm wondering how you make the picturebox (or whatever) ask where the image is located to draw it in the picturebox.
Example:
Database:
tblAnimals contains
- Dog
- Cat
Now in my form it auto adds 2 pictureboxes without containing any images. Now it should ask for the image location (C/Document/Pictures/Dog.jpg) and draw that in the picturebox.
I have no idea how to this, anyone has any ideas?
Already thx :)
This is my acctual code now:
Dim bytTeller As Byte
Dim objdtsProducten As New dtsProducten
Dim objtblProductenTA As New dtsProductenTableAdapters.tblProductenTableAdapter
Dim dtrProduct As dtsProducten.tblProductenRow
objtblProductenTA.Fill(objdtsProducten.tblProducten)
For Each dtrProduct In objdtsProducten.tblProducten
Dim ptbKnop As New PictureBox
ptbKnop.Name = dtrProduct.ProductID
ptbKnop.Text = dtrProduct.ProductNaam
ptbKnop.Size = New Size(80, 40)
ptbKnop.Location = New Point((bytTeller Mod 4) * 90, (bytTeller \ 4) * 50)
AddHandler ptbKnop.Click, AddressOf KnopGeklikt
Me.Controls.Add(ptbKnop)
bytTeller += 1
Next
I know I can open a picture with this:
With OpenFileDialog1
.CheckFileExists = True
.ShowReadOnly = False
.Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
.FilterIndex = 2
If .ShowDialog = DialogResult.OK Then
' Load the specified file into a PictureBox control.
Dog.Image = Image.FromFile(.FileName)
End If
End With
But I don't know the name of the picture yet (see DOG)
Question
Guest
Hi,
I'm currently working on a program that automaticly adds pictureboxes whenever you add an entree to a database (access).
I got that working, but Now I'm wondering how you make the picturebox (or whatever) ask where the image is located to draw it in the picturebox.
Example:
Database:
tblAnimals contains
- Dog
- Cat
Now in my form it auto adds 2 pictureboxes without containing any images. Now it should ask for the image location (C/Document/Pictures/Dog.jpg) and draw that in the picturebox.
I have no idea how to this, anyone has any ideas?
Already thx :)
This is my acctual code now:
I know I can open a picture with this:
But I don't know the name of the picture yet (see DOG)
Edited by GuestLink to comment
Share on other sites
3 answers to this question
Recommended Posts