473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to add a file to a usercontrol's resources

I want to include a help file with a usercontrol so that I can raise it with
the control's context menu.
I've been searching for how to do that and have concluded that the file can
be added as a resource but can find only examples of how to add other
things - usually strings.
1. Is that really the way I should do it?

2. Can you give of point to a sample code that adds a file to the resources?

Thanks
Dec 22 '07 #1
5 2270


"Academia" wrote:
I want to include a help file with a usercontrol so that I can raise it with
the control's context menu.
I've been searching for how to do that and have concluded that the file can
be added as a resource but can find only examples of how to add other
things - usually strings.
1. Is that really the way I should do it?

2. Can you give of point to a sample code that adds a file to the resources?

Thanks
You can add a file as a resource and retrieve it with
GetManifestResourceStream. There is example code here:

http://msdn2.microsoft.com/en-us/library/aa984367.aspx
>
Dec 22 '07 #2
I thought "How nice, so simple once you learn how".

Then I realized that GetManifestResourceStream returns a stream and
Help.ShowHelp requires a file name!

Do I need to actually copy the resource into a temp file.
Thanks for the help.

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:A5**********************************@microsof t.com...
>
You can add a file as a resource and retrieve it with
GetManifestResourceStream. There is example code here:

http://msdn2.microsoft.com/en-us/library/aa984367.aspx
>>

Dec 22 '07 #3
I copied it to a temp file and it works OK.
Still wondering if all that is required.

Thanks for pointing out that site.

"Academia" <ac************@a-znet.comwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>I thought "How nice, so simple once you learn how".

Then I realized that GetManifestResourceStream returns a stream and
Help.ShowHelp requires a file name!

Do I need to actually copy the resource into a temp file.
Thanks for the help.

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:A5**********************************@microsof t.com...
>>
You can add a file as a resource and retrieve it with
GetManifestResourceStream. There is example code here:

http://msdn2.microsoft.com/en-us/library/aa984367.aspx
>>>


Dec 23 '07 #4
If you really need a file, then it is probably simpler and faster just to
package it with your application in an installer/deployment project. I did
not realize passing a stream for the help was not an option or I would have
pointed that out. Sorry!

"Academia" wrote:
I copied it to a temp file and it works OK.
Still wondering if all that is required.

Thanks for pointing out that site.

"Academia" <ac************@a-znet.comwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
I thought "How nice, so simple once you learn how".

Then I realized that GetManifestResourceStream returns a stream and
Help.ShowHelp requires a file name!

Do I need to actually copy the resource into a temp file.
Thanks for the help.

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:A5**********************************@microsof t.com...
>
You can add a file as a resource and retrieve it with
GetManifestResourceStream. There is example code here:

http://msdn2.microsoft.com/en-us/library/aa984367.aspx


Dec 23 '07 #5
I like your suggestion to use GetManifestResourceStream.
Making a temp file and passing it works well.

Thanks again

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:30**********************************@microsof t.com...
If you really need a file, then it is probably simpler and faster just to
package it with your application in an installer/deployment project. I
did
not realize passing a stream for the help was not an option or I would
have
pointed that out. Sorry!

"Academia" wrote:
>I copied it to a temp file and it works OK.
Still wondering if all that is required.

Thanks for pointing out that site.

"Academia" <ac************@a-znet.comwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>I thought "How nice, so simple once you learn how".

Then I realized that GetManifestResourceStream returns a stream and
Help.ShowHelp requires a file name!

Do I need to actually copy the resource into a temp file.
Thanks for the help.

"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:A5**********************************@microsof t.com...

You can add a file as a resource and retrieve it with
GetManifestResourceStream. There is example code here:

http://msdn2.microsoft.com/en-us/library/aa984367.aspx





Dec 24 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: yongwei | last post by:
I have a user control that used to work fine. But after I moved the project to another folder, one of the user control won't generate a .resouce file after rebuild, and the form contains the user...
0
by: yongwei | last post by:
After I make some changes to my program, I got a run time error each time, see following. Seems to me like the compiler did not create a GraphicInput.resources in \obj sub dir. the compiler did...
7
by: Jon Davis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;329014 Adding the code at this URL results in an error message: An unhandled exception of type...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
1
by: Agnes | last post by:
I design my own lable and save as usercontrol , In my form (another project myProject), i will use this usercontrol , however, it somestiems work fine but somestimes fail. now , I got a serious...
2
by: Steve | last post by:
This is a weird one. I have a series of "SmartParts" which are CAB (Composite Application Block) Views which are finally just UserControls (99% of the time) Anyway, I layout my UserControl in...
4
by: Martin | last post by:
Hi everyone ! For those who haven't read my previous post, I have a problem with a UserControl. When I try to display it on a form, controls seem to appear one after one. In the following...
4
by: moondaddy | last post by:
I have a user control located in the following path: projectFolder/PropertyControls/myControl.xaml and in myControl.xaml I have a reference to a resource dictionary like this: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.