|
-
Oct 21st, 2003, 12:43 PM
#1
Thread Starter
Addicted Member
Add texts to a RichtextBox with file load
Is there a way to add texts before a RichTextBox file load? Here's my situation. I have a string variable that holds a bunch of data in it. Below is how I load the file into the RichTextBox.
Code:
richTextBox1.LoadFile(filePath & strFileName, RichTextBoxStreamType.RichText)
However, I want to add the string variable to the RichTextBox along with the data that comes from the file load. Another word, I want to combine the two and store into one richtextbox. Is there a way to do this?
Any help is greatly appreciated!
ljCharlie
-
Oct 21st, 2003, 01:31 PM
#2
Uh, combing a string and text file into 1 textbox?
Just make the textbox equal to the string either before you load the text, then when you load the text do something like textbox.text += and then the code to load the file.
-
Oct 21st, 2003, 01:43 PM
#3
Thread Starter
Addicted Member
Thank you very much for the suggestion. Here's what I have.
Code:
richtextbox1.text = strVariable
richtextbox1.text += richTextBox1.LoadFile(filePath & strFileName, RichTextBoxStreamType.RichText)
But still doesn't work. There is a blue underline on this line richTextBox1.LoadFile(filePath & strFileName, RichTextBoxStreamType.RichText)
ljCharlie
-
Oct 21st, 2003, 02:56 PM
#4
you could try this ...
VB Code:
[Color=Blue]Dim[/COLOR] strText [Color=Blue]As[/COLOR] [Color=Blue]String[/COLOR] = "some text" & Environment.NewLine [Color=Green]'///[/COLOR] [Color=Green]add[/COLOR] [Color=Green]newline[/COLOR] [Color=Green]if[/COLOR] [Color=Green]you[/COLOR] [Color=Green]want[/COLOR] [Color=Green]the[/COLOR] [Color=Green]string[/COLOR] [Color=Green]a[/COLOR] [Color=Green]line[/COLOR] [Color=Green]above[/COLOR] [Color=Green]the[/COLOR] [Color=Green]loaded[/COLOR] [Color=Green]file.
[/COLOR] [Color=Blue]With[/COLOR] RichTextBox1
.LoadFile("C:\test.txt", RichTextBoxStreamType.PlainText) [Color=Green]'///[/COLOR] [Color=Green]first[/COLOR] [Color=Green]load[/COLOR] [Color=Green]the[/COLOR] [Color=Green]file.
[/COLOR] .SelectionStart = 0 [Color=Green]'///[/COLOR] [Color=Green]go[/COLOR] [Color=Green]to[/COLOR] [Color=Green]beginning[/COLOR] [Color=Green]of[/COLOR] [Color=Green]text[/COLOR] [Color=Green]in[/COLOR] [Color=Green]richtextbox.
[/COLOR] .SelectedText = strText [Color=Green]'///[/COLOR] [Color=Green]then[/COLOR] [Color=Green]add[/COLOR] [Color=Green]the[/COLOR] [Color=Green]other[/COLOR] [Color=Green]string[/COLOR] [Color=Green]to[/COLOR] [Color=Green]the[/COLOR] [Color=Green]beginning.
[/COLOR] .SelectionStart = .TextLength [Color=Green]'///[/COLOR] [Color=Green]then[/COLOR] [Color=Green]back[/COLOR] [Color=Green]to[/COLOR] [Color=Green]the[/COLOR] [Color=Green]end[/COLOR] [Color=Green]of[/COLOR] [Color=Green]the[/COLOR] [Color=Green]text[/COLOR] [Color=Green]in[/COLOR] [Color=Green]richtextbox.
[/COLOR] [Color=Blue]End[/COLOR] [Color=Blue]With[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 21st, 2003, 02:57 PM
#5
You should post error messages when you get them.
This is a bit hard when VS.NET isn't in front of me, but you could always load into a richtextbox that you make with code, make the string equal to your textbox and lod the other file into the textbox made with code, then use richtextbox1 += richtextbox2
If you're loading a file with the richtextbox loading function, It is a little more limited when trying to do things like this.
Tough that solution I just gave proably isn't the best. Later on when I'm in front of my other computer with VS.NET installed, I can figure out a much much better way. That or I'm sure osmeone else will give one
-
Oct 21st, 2003, 03:19 PM
#6
Thread Starter
Addicted Member
Thanks, dynamic_sysop! Your code seems to work.
Thank you everyone for helping me out. I'm greatly appreciate the help.
ljCharlie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|