473,385 Members | 1,409 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,385 software developers and data experts.

RichTextBox

I have RichTextBox in my dialog. Currently, I am loading the content from a
file. Is there anyway to have the text 'binded' to it during compile time ?
The idea is not to distribute the rtf file when installing the application.
Nov 16 '05 #1
7 7038
Could you use a resource file?

"Tank" wrote:
I have RichTextBox in my dialog. Currently, I am loading the content from a
file. Is there anyway to have the text 'binded' to it during compile time ?
The idea is not to distribute the rtf file when installing the application.

Nov 16 '05 #2
Er.. how ? The problem is the text consists of a mix of bolded and
non-bolded text. Also some words use different font.

"Paul Ledger" <Pa********@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com...
Could you use a resource file?

"Tank" wrote:
I have RichTextBox in my dialog. Currently, I am loading the content from a file. Is there anyway to have the text 'binded' to it during compile time ? The idea is not to distribute the rtf file when installing the application.

Nov 16 '05 #3
true but the underlying RTF is just tagged text....

{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl {\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 Here is the text\par
}

"Tank" wrote:
Er.. how ? The problem is the text consists of a mix of bolded and
non-bolded text. Also some words use different font.

"Paul Ledger" <Pa********@discussions.microsoft.com> wrote in message
news:6C**********************************@microsof t.com...
Could you use a resource file?

"Tank" wrote:
I have RichTextBox in my dialog. Currently, I am loading the content from a file. Is there anyway to have the text 'binded' to it during compile time ? The idea is not to distribute the rtf file when installing the application.


Nov 16 '05 #4
You can include the RTF file as an embedded resource and load it from
the assembly.

Add the file:
Project -> Add Existing Item

Right click on it in Solution Explorer and select:
Build Action -> Embedded Resource

Then use code like this to load it:

using System.Reflection;

Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream =
assembly.GetManifestResourceStream("RTFtest.testFi le.rtf"))
{
richTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
}

where 'RTFtest' is the default namespace for the project.

- Magnus

"Tank" <an*******@discussions.microsoft.com> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
I have RichTextBox in my dialog. Currently, I am loading the content from a file. Is there anyway to have the text 'binded' to it during compile time ? The idea is not to distribute the rtf file when installing the application.

Nov 16 '05 #5
I have a rtf file "abc.rtf", namespace is MyNamespace.

assembly.GetManifestResourceStream("MyNamespace.ab c.rtf")) gave me an error.

Is that the correct way to specify the resource name ?
"Magnus Krisell" <ma******@NOSPAMstudent.liu.se> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
You can include the RTF file as an embedded resource and load it from
the assembly.

Add the file:
Project -> Add Existing Item

Right click on it in Solution Explorer and select:
Build Action -> Embedded Resource

Then use code like this to load it:

using System.Reflection;

Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream =
assembly.GetManifestResourceStream("RTFtest.testFi le.rtf"))
{
richTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
}

where 'RTFtest' is the default namespace for the project.

- Magnus

"Tank" <an*******@discussions.microsoft.com> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
I have RichTextBox in my dialog. Currently, I am loading the content
from a
file. Is there anyway to have the text 'binded' to it during compile
time ?
The idea is not to distribute the rtf file when installing the

application.


Nov 16 '05 #6
Thanks. I got it. Please ignore my last post.

"Magnus Krisell" <ma******@NOSPAMstudent.liu.se> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
You can include the RTF file as an embedded resource and load it from
the assembly.

Add the file:
Project -> Add Existing Item

Right click on it in Solution Explorer and select:
Build Action -> Embedded Resource

Then use code like this to load it:

using System.Reflection;

Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream =
assembly.GetManifestResourceStream("RTFtest.testFi le.rtf"))
{
richTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
}

where 'RTFtest' is the default namespace for the project.

- Magnus

"Tank" <an*******@discussions.microsoft.com> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
I have RichTextBox in my dialog. Currently, I am loading the content
from a
file. Is there anyway to have the text 'binded' to it during compile
time ?
The idea is not to distribute the rtf file when installing the

application.


Nov 16 '05 #7
Thanks. It works fine that way.

Another question is :

How do I get the default namespace of the project programatically ? The idea
is not to hardcode the parameter "RTFtest.testFile.rtf" so that I can do
something like this :

assembly.GetManifestResourceStream(GetDefaultProjN ameSpace()+".testFile.rtf"
));

Thanks in advance.
"Magnus Krisell" <ma******@NOSPAMstudent.liu.se> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
You can include the RTF file as an embedded resource and load it from
the assembly.

Add the file:
Project -> Add Existing Item

Right click on it in Solution Explorer and select:
Build Action -> Embedded Resource

Then use code like this to load it:

using System.Reflection;

Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream =
assembly.GetManifestResourceStream("RTFtest.testFi le.rtf"))
{
richTextBox.LoadFile(stream, RichTextBoxStreamType.RichText);
}

where 'RTFtest' is the default namespace for the project.

- Magnus

"Tank" <an*******@discussions.microsoft.com> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
I have RichTextBox in my dialog. Currently, I am loading the content
from a
file. Is there anyway to have the text 'binded' to it during compile
time ?
The idea is not to distribute the rtf file when installing the

application.


Nov 16 '05 #8

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

Similar topics

0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
3
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
1
by: Nathan Carroll | last post by:
In an mdi environment I constructed a child for with a richtextbox control that is used to load .rtf's. This works fine on the intiatial load of the form but when for is closed and reopened later...
12
by: M O J O | last post by:
Hi, If I inside a thread creates a RichTextBox and only use this inside the thread, will there be any thread problems? I need to convert between Text and RTF inside a thread. Thanks!! M...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
1
by: bmerlover | last post by:
I'm having trouble reading quotations inside the richTextBox when a file is opened on to it. I've tried a couple different methods, most of them didn't compile. I came across one that does compile...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.