c# - How do I use Resource File/Path on [ToolboxBitmap("MyResourcePictureFileName")] -
developing custom control , want place custom icon. trying use solution resource file within [toolboxbitmap("myresourcepicturefilename")] property icon not setting instead showing default user control icon. whereas fixed path works fine
e.g. [toolboxbitmap( @"c:\frame.bmp")]
but don't want use absolute location.
question: how can use custom image/icon of control
here code:
note: frame.bmp in resource , action property=embedded resource build
// dont want use --> [toolboxbitmap( @"c:\frame.bmp")] [toolboxbitmap("resources.frame.bmp")] [toolboxitem(true)] public partial class mycustompanelcontrol : panel { ................ ................ }
please advice,
thanks
[toolboxbitmap("resources.frame.bmp")]
the resource name not correct, pretty chronic problem toolbox bitmaps btw. first make sure embedded bitmap correctly, not use resource designer:
- project > add existing item > select bitmap file
- select added item in solution explorer window. in properties window set build action "embedded resource"
- project > properties > application tab > default namespace property matters, that's name use instead of "resources"
- double-check , run ildasm.exe. double-click manifest, should see entry resembles:
.mresource public defaultnamespace.frame.bmp { // offset: 0x000000b8 length: 0x000004f6 }
note .mresource name, that's 1 put in attribute. fix:
[toolboxbitmap("defaultnamespace.frame.bmp")]
replacing "defaultnamespace" actual name.
Comments
Post a Comment