开发者

Displaying an image

I am using vb.net running a backend MS.Access database and I am wondering what is the code that I can use to disp开发者_如何转开发lay a picture of an image when the field name is selected.

My MS Access "field" name is Cars_Types: in the files I have the data "GM, Chrysler, Toyota, Honda, and Ford".

The name of my database is ModelCars.accdb

The pictures are not coded into the database instead I would like them to be coded into the VB.NET program.

I have the database working correctly within my VB.NET program but I am having trouble getting the images to appear.


If you just have the five images or so, you could store them in your .NET application as local resources. When you retrieve an associated record from the database, display it (in whatever context you need, I copied the msdn example here):

Me.Background= My.Resources.GMImage

Edit: To select which image to use, if you have a string in the DB of the various car types, just use a switch statement:

Select Case(carType)
    Case "GM": me.picCarPhotos = My.Resources.GMImage
    Case "Ford": me.picCarPhotos = My.Resources.FordImage
End Select

Disclaimer: I'm more familiar with C# so this may need some tweaking if my VB is off.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜