Add resources to a control subclass


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm sub classing a toolstrip and want to preadd some buttons (just like you do on you RichTextboxToolStrip control). I can add the designer file, with the code that adds the toolstripbuttons/combos/etc. but can't figure out how to add the resource file with the images for the buttons. If I add a resource file, I have to add a dependency manually to the main file. If I add resources to it via the property sheet, it gives me a warning about corrupting the form/control.



So, how do I add a resource to the control?
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Generally, on a ToolStripButton, you can just set the Image on the property sheet, and the designer will automatically create the .resx file for your component and add it to the project (if you select local resource in the editor for the image).  You can also select project resource from there, which will use the project's .resx file.

You should never have to manually add an .resx file to a component... when you set a property that tries to use the resource file, it will create one automatically the first time it needs one.

Now, if it's giving you that error when you just try to set the Image property on a tool strip button, then there might be other problems...

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Doh...Yep, there is it, the Items collection. One of these days I'll start getting .NET enough to stop asking silly questions Blush In the mean time, thanks for you help!
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Hehe, everyone has to learn.  It's better to ask and learn from the answer than to bang your head for 2 days trying to figure it out Smile
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search