Resolved Picture Box Problem: Imaging loading using a combo box

ChrisMayhew

Member
Joined
Apr 2, 2009
Messages
12
Programming Experience
1-3
Hey

I am having a bit of an annoying picture box problem, I have a picture box on my form along with a combo box with a number of different options.

So anyway when a combo box item is selected I want it to look in the dataset for the selected item's row and pick out the image to load and then using an IF statement it sets the image (or should)

VB.NET:
Dim RaceImg As String = DS.Tables("tblRaces").Rows(ID).Item("RaceImg")
        
If RaceImg = "AusGP" Then
      GP_Picture.Image = Image.FromFile("./Track Images/AusGP.png")
ElseIf RaceImg = "MalGP" Then
      GP_Picture.Image = Image.FromFile("./Track Images/MalGP.png")
End If


I have tried a number of different ways to get this working, I have tried them in the resources for the program and also tried the following code
VB.NET:
GP_Picture.Image = "./Track Images/AusGP.png"

If you get any of that then any help would be great :)
It seems like the picture box isn't redrawing or something?

Thanks,
Chris

Edit: Just to add it will load the first image which is the AusGP because thats the first option in the combo box, after that none of the others will load.
 
Last edited:
Where does this come from?
VB.NET:
Dim RaceImg As String = DS.Tables("tblRaces").Rows([B][U]ID[/U][/B]).Item("RaceImg")

The ID is the combo box's selected index which will then look up the correct row in the database for the selected item.

This code by the way is on the combo box's selected index changed so it runs this every time someone selects a new item.

Using the ID on other parts of the code for setting text into labels seems to work fine but it doesn't seem to work for this image.
 
Last edited:
Just to update I have managed to get this working.. Stupid mistake on my part....

Basically I forgot to update the actual database the program :)o) is using with the one I had updated so it only have the RaceImg column for the AusGP and not any of the others.

Sorry for wasting your time :eek:
 
Back
Top