![]() |
| | #1 |
| Registered User Join Date: Dec 2005
Posts: 51
| Control with image loaded from file, cant view in designer Parameter is not valid. at System.Drawing.Bitmap..ctor(String filename) at Card_Creator.Item_Preview.Item_Preview_Load(Object sender, EventArgs e) in C:\Users\Jeremy\Desktop\SVN\Source Code\Card Creator\Card Creator\Item Preview.cs:line 72 I have seen this issue a few times in the office with trying to reference config files that are loaded in. Is there a way to work around this so I can load something in and not have the designer barf on it? [Edit: Spelling] |
| JeremyCAFE is offline | |
| | #2 |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,122
| Check the (inherited) DesignMode property. If this is True, don't load the image. This property won't work in the constructor, check it in OnLoad.
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
| Magos is offline | |
| | #3 |
| Registered User Join Date: Dec 2005
Posts: 51
| Thank you. this is perfect for solving the issue. |
| JeremyCAFE is offline | |
| | #4 |
| Registered User Join Date: Dec 2005
Posts: 51
| hmm, so the solution is not working if the control with the check is double embedded. (used on a parent control, in which that parent control is used on another control) Code: if(!DesignMode)
{
bmpCardBackground = new Bitmap("tressure_bg.png");
}
|
| JeremyCAFE is offline | |
| | #5 | |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,122
| Quote:
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. | |
| Magos is offline | |
| | #6 |
| Registered User Join Date: Dec 2005
Posts: 51
| I am getting the same error I was getting before on the top most parent now. Control 1 (with loaded image) is put onto control 2. Control 2 is put onto Form. Form cannot load and is giving the error shown in first post. Builds fine, just can't view it in the designer. |
| JeremyCAFE is offline | |
| | #7 |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,122
| Try using a full path (C:\Folder1\Folder2\Image.png) instead of a relative that you use now. Also you spell "treasure" as "tressure", typo or error? You could also try another image, like a jpg. Perhaps your png is saved in a weird format that the bitmap class can't handle? That's all I can think of now.
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
| Magos is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A development process | Noir | C Programming | 30 | 10-28-2009 04:24 AM |
| Memory Address | kevinawad | C++ Programming | 18 | 10-19-2008 10:27 AM |
| Need Help Fixing My C Program. Deals with File I/O | Matus | C Programming | 7 | 04-29-2008 07:51 PM |
| C++ std routines | siavoshkc | C++ Programming | 33 | 07-28-2006 12:13 AM |
| Unknown Memory Leak in Init() Function | CodeHacker | Windows Programming | 3 | 07-09-2004 09:54 AM |