How to Store Multiple Images in the Visual Studio Application Import to Resources ?

mond007

Active member
Joined
Apr 26, 2010
Messages
37
Location
near Solihull, Birmingham UK
Programming Experience
10+
Hi
I have spent quite some time developing a Maintenance application. See the following link if need be.
http://www.vbdotnetforums.com/xml/60658-create-effective-xml-schema-data-load-dilemma.html

I am now at the point where I need to know how to store hundreds of images within the Application. Clearly I will have an Open Dialogue box that will allow the locate/storage an image. I think I would store the identified ?image name? into the ?AnswerImage? field below and then assume a standard application path i.e. c:\project\images\

See highlighted line in the XML Schema Definition below. (i.e. AnswerImage)
VB.NET:
        With QuestionAnswerData.Tables("Questions")
            .Columns.Add("QuestionID", GetType(Integer))
            .Columns.Add("QuestionNo", GetType(String))
            .Columns.Add("Question", GetType(String))
            .Columns.Add("AnswerSection", GetType(String))
            .Columns.Add("AnswerSectionColor", GetType(String))
            .Columns.Add("[B]AnswerImage[/B]", GetType(String))
            .Columns.Add("AnswerHyperlink", GetType(String))
        End With
 
        With QuestionAnswerData.Tables("Answers")
            .Columns.Add("QuestionID", GetType(Integer))
            .Columns.Add("AnswerRef", GetType(String))
            .Columns.Add("AnswerFormat", GetType(String))
            .Columns.Add("AnswerColour", GetType(String))
            .Columns.Add("AnswerDescription", GetType(String))
        End With
Screen-Shot.jpg
The Question is how and where to store the images ?.
I have tried searching to see how I can import images into the ?Resources? but to no avail. And even so this would be built into the executable so no joy there when I want to change/add. Hmmm.

Since, the application comes with a few hundred images and allows the user to add images of their own, I guess the way to do this would be to have all the images within a ?Images? folder and the read the relevant image at run time.

Would appreciate some guidance. ?
Thanks in advance. Kuldip
 
Hi,

I would suggest that you store all your images in a location on your Hard Drive and then all you have in your project is a String Path to that image which can be changed at any time in your XML file. When you then need to display an image for any answer based on that String Path then you can just call:-

YourPictureBox.Image = Image.FromFile("YourImagePath")
'or
YourPictureBox.Load("YourImagePath")


Hope that helps.

Cheers,

Ian
 
Indeed. Thanks

I was also planning to use the Image.FromFile("YourImagePath") you suggest to copy the image file from where ever the user selected to the /images folder so that all images are retained in a central area.

The only string that gets saved to the AnswerImage is the name of the image not the path. The path will always be /images subdirectory.

I shall build the Maintenance screen which will save the Header and Detail Records first and then work out the images part. Searching for the AnswerNo and displaying the Answer Details is easy as I already cracked that.

Thanks again. Kuldip.
 
Hi
Can anyone help with creating a content management system for the above XML Database layout. The way I wold tackle this would be too :

1) create a Form with two ListBoxes (one for the Parent Record and one for the Child).

2) On form startup read in all the parents records from the XML into the Listbox1 likewise for the child records into ListBox2

3) Create action buttons, ?Add Parent?, ?Modify Parent?, and Deleted highlighted Record in the ListBox1.

4) Create action buttons, ?Add Child?, ?Modify Child?, and Deleted highlighted Child Record in the ListBox2.

5) Programme up all code behind these buttons (ensure referential integrity). i.e. when deleting a parent delete child records too.

I am just wondering if there is a better way ?
I thought I saw a youtube on saving parent/child record using form fields but can find it again.

I thought of using DataGridView but this is not user friendly !!.

Any ideas ?
Thanks in advance Kuldip.
 
Hi,

You are asking a completely different question to the title that your thread suggests so please remember to create a new thread for new questions.

That said, FORGET about XML now! you use that to read and write your information from and to a file from a Dataset. That's it, done and dusted!

The data in your project in now in a Dataset with two tables which are relationally linked so you now need to look into Data Binding Controls from that Dataset.

Just have a look around the forum for Parent/Child Data Binding and I gave you a big hint where to look in your last thread.

Cheers,

Ian
 

Latest posts

Back
Top