Solved

Help needed| Visual C# 2015 allow user to load custom image as resource

Posted on 2016-10-16
3
22 Views
Last Modified: 2016-11-05
I am writing an application in Visual C# 2015 that produces reports. On the header I display a default logo (this uses a linked resource that is installed during install).

I want to enable the user to select their own image to use in the header. Can the resource file be replaced at runtime by user selected image.

Alternately, I was thinking of using a "setting" that is string which initially has say "Use Resource Image". If the user selects their won image then I change the setting to path and name of their image.

In the rendering part of the report I check the setting and use either the resource or user selected file dependent on the setting value.

I think this would work but if they inadvertently move their image file the program will have issues. It would be good if the program could load their image as an embedded image so it is always available.

Any help much appreciated.
0
Comment
Question by:David Huisman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 36

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points (awarded by participants)
ID: 41846364
I do not think you can create a resource at run-time, but you could capture the image file and store as a binary in a database table or in the app data folder of your application. I prefer the database approach as it is safely stored in a central location that you can back it up.
0
 
LVL 34

Accepted Solution

by:
sarabande earned 250 total points (awarded by participants)
ID: 41846777
two choices if you want to make a customized application:

(1) put the image into a second rc file, say logo.rc.
     add the customers logo into logo<customer name>.rc
     add the second rc file to project with option 'exclude from build=yes"
     make a new release configuration where the logo.rc is excluded and the other rc is included.

(2) move your resources into a dll resource project.
     create a second dll Project with exchanged (customized) resources
     at customer's setup choose the right dll to be installed.

alternatively - and maybe easier - is to have both Images in the resource file but load the wished one dynamically into an empty frame control at runtime.

Sara
0
 
LVL 34

Expert Comment

by:sarabande
ID: 41875268
Unfortunately the Asker didn't respond to the given solutions. But as both the answers are valid solutions in my experience, the answers's should be added to the knowledgebase.

Sara
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question