Not all roads lead to rome...
-
Recently I stumbled across a nice little bug in .NET while working with RichTextBoxes... Consider the following code snipplet:
RichTextBox _rtb = new RichTextBox();
// ...
// fill the RTB
// ...// get all the formatted Text in RTF format:
string rtf1 = _rtb.Rtf;// alternative way:
_rtb.Select(0, _rtb.Text.Length); // select everything
string rtf2 = _rtb.SelectedRtf; // get the selectionWhat do you think - is it reasonable to assume that
rtf1
contains the same RTF asrtf2
? Solution coming up later...Regards, mav -- Black holes are the places where God divided by 0...
-
Recently I stumbled across a nice little bug in .NET while working with RichTextBoxes... Consider the following code snipplet:
RichTextBox _rtb = new RichTextBox();
// ...
// fill the RTB
// ...// get all the formatted Text in RTF format:
string rtf1 = _rtb.Rtf;// alternative way:
_rtb.Select(0, _rtb.Text.Length); // select everything
string rtf2 = _rtb.SelectedRtf; // get the selectionWhat do you think - is it reasonable to assume that
rtf1
contains the same RTF asrtf2
? Solution coming up later...Regards, mav -- Black holes are the places where God divided by 0...
mav.northwind wrote:
What do you think - is it reasonable to assume that rtf1 contains the same RTF as rtf2?
No, rtf1 will included document info too. rtf2 might attach info differently (as needed). [update] what I said is actually well documented [update]
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
mav.northwind wrote:
What do you think - is it reasonable to assume that rtf1 contains the same RTF as rtf2?
No, rtf1 will included document info too. rtf2 might attach info differently (as needed). [update] what I said is actually well documented [update]
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)While this may be true, it's not what I meant (btw. where did you find this information?). Even if there's no additional document info, there's a visible difference.
_rtb.Rtf
contains an additional newline (\par
) at the end and switches the font back to the RTB's default font. So if you have 2 RTB's and want to insert the first one's contents at a given position into the second one, you won't get the correct results, unless you don't use_rtb.Rtf
but_rtb.SelectedRtf
.Regards, mav -- Black holes are the places where God divided by 0...
-
While this may be true, it's not what I meant (btw. where did you find this information?). Even if there's no additional document info, there's a visible difference.
_rtb.Rtf
contains an additional newline (\par
) at the end and switches the font back to the RTB's default font. So if you have 2 RTB's and want to insert the first one's contents at a given position into the second one, you won't get the correct results, unless you don't use_rtb.Rtf
but_rtb.SelectedRtf
.Regards, mav -- Black holes are the places where God divided by 0...
mav.northwind wrote:
btw. where did you find this information?
MSDN docs! :) Rtf is used for 'loading' a complete document. SelectedRtf is for 'inserting/selecting' a chunk of RTF.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
mav.northwind wrote:
btw. where did you find this information?
MSDN docs! :) Rtf is used for 'loading' a complete document. SelectedRtf is for 'inserting/selecting' a chunk of RTF.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)leppie wrote:
MSDN docs! [Smile]
:) oh come on! I was hoping for a link about document information in RTF documents... Nevertheless,
Rtf
will give you a newline that simply isn't there.Regards, mav -- Black holes are the places where God divided by 0...
-
Recently I stumbled across a nice little bug in .NET while working with RichTextBoxes... Consider the following code snipplet:
RichTextBox _rtb = new RichTextBox();
// ...
// fill the RTB
// ...// get all the formatted Text in RTF format:
string rtf1 = _rtb.Rtf;// alternative way:
_rtb.Select(0, _rtb.Text.Length); // select everything
string rtf2 = _rtb.SelectedRtf; // get the selectionWhat do you think - is it reasonable to assume that
rtf1
contains the same RTF asrtf2
? Solution coming up later...Regards, mav -- Black holes are the places where God divided by 0...
Working with a huge blob of RTF text is a nightmare… I'd much prefer using WPF's RichTextBox control. It provides a structured representation of all the elements in the document (much like HTML or XML). You might want to consider embedding one in your Windows Forms project.
So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
-
leppie wrote:
MSDN docs! [Smile]
:) oh come on! I was hoping for a link about document information in RTF documents... Nevertheless,
Rtf
will give you a newline that simply isn't there.Regards, mav -- Black holes are the places where God divided by 0...
mav.northwind wrote:
I was hoping for a link about document information in RTF documents...
That wouldn't be much use, they change them daily in an attempt to make Google look bad!