Measure an RTF string - DOTNET

This is a discussion on Measure an RTF string - DOTNET ; Hello I have a RichTextBox in my .NET application. Is there a way to measure the length of the appeared string in it? I mean is there something like Graphics.MeasureString method that accepts MyRichTextBox.Rtf as the input instead of a ...

+ Reply to Thread
Results 1 to 4 of 4

Measure an RTF string

  1. Default Measure an RTF string

    Hello

    I have a RichTextBox in my .NET application. Is there a way to measure the
    length of the appeared string in it? I mean is there something like
    Graphics.MeasureString method that accepts MyRichTextBox.Rtf as the input
    instead of a simple text?

    Thanks in advance

    Hamed




  2. Default Re: Measure an RTF string

    Short answer is "no".

    I think however that you can discover the position of a character in the
    rich text box. This may serve as a workaround.

    The big problem of course is that a line of text may contain a lot of
    different fonts and sizes. MeasureString only cares about a simple
    string of characters.

    --
    Bob Powell [MVP]
    Visual C#, System.Drawing

    Ramuseco Limited .NET consulting
    http://www.ramuseco.com

    Find great Windows Forms articles in Windows Forms Tips and Tricks
    http://www.bobpowell.net/tipstricks.htm

    Answer those GDI+ questions with the GDI+ FAQ
    http://www.bobpowell.net/faqmain.htm

    All new articles provide code in C# and VB.NET.
    Subscribe to the RSS feeds provided and never miss a new article.





    Hamed wrote:
    > Hello
    >
    > I have a RichTextBox in my .NET application. Is there a way to measure the
    > length of the appeared string in it? I mean is there something like
    > Graphics.MeasureString method that accepts MyRichTextBox.Rtf as the input
    > instead of a simple text?
    >
    > Thanks in advance
    >
    > Hamed
    >
    >
    >


  3. Default Re: Measure an RTF string

    > Hamed wrote:
    >> Hello
    >>
    >> I have a RichTextBox in my .NET application. Is there a way to measure
    >> the
    >> length of the appeared string in it? I mean is there something like
    >> Graphics.MeasureString method that accepts MyRichTextBox.Rtf as the input
    >> instead of a simple text?
    >>
    >> Thanks in advance
    >>
    >> Hamed


    You mean there is no tools or workaround the RTF? How can I measure this? I
    have a lot of international characters, formating characters, colored and
    bold characters, etc.


    "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
    news:uykitMdVHHA.488@TK2MSFTNGP06.phx.gbl...
    > Short answer is "no".
    >
    > I think however that you can discover the position of a character in the
    > rich text box. This may serve as a workaround.
    >
    > The big problem of course is that a line of text may contain a lot of
    > different fonts and sizes. MeasureString only cares about a simple string
    > of characters.
    >
    > --
    > Bob Powell [MVP]
    > Visual C#, System.Drawing
    >
    > Ramuseco Limited .NET consulting
    > http://www.ramuseco.com
    >
    > Find great Windows Forms articles in Windows Forms Tips and Tricks
    > http://www.bobpowell.net/tipstricks.htm
    >
    > Answer those GDI+ questions with the GDI+ FAQ
    > http://www.bobpowell.net/faqmain.htm
    >
    > All new articles provide code in C# and VB.NET.
    > Subscribe to the RSS feeds provided and never miss a new article.
    >
    >
    >
    >
    >
    >>
    >>



  4. Default Re: Measure an RTF string

    No, I guess not. The RTF control is "as is", which means there's nothing
    more (not much, at least) than documented.

    You can get the y-coordinate "after the last line", but not the x-coordinate
    ("line width if there's only one line").

    Christian

    "Hamed" <hamed@raymehr.com> wrote in message
    news:ezQrWUWWHHA.600@TK2MSFTNGP05.phx.gbl...
    >> Hamed wrote:
    >>> Hello
    >>>
    >>> I have a RichTextBox in my .NET application. Is there a way to measure
    >>> the
    >>> length of the appeared string in it? I mean is there something like
    >>> Graphics.MeasureString method that accepts MyRichTextBox.Rtf as the
    >>> input
    >>> instead of a simple text?
    >>>
    >>> Thanks in advance
    >>>
    >>> Hamed

    >
    > You mean there is no tools or workaround the RTF? How can I measure this?
    > I
    > have a lot of international characters, formating characters, colored and
    > bold characters, etc.
    >
    >
    > "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
    > news:uykitMdVHHA.488@TK2MSFTNGP06.phx.gbl...
    >> Short answer is "no".
    >>
    >> I think however that you can discover the position of a character in the
    >> rich text box. This may serve as a workaround.
    >>
    >> The big problem of course is that a line of text may contain a lot of
    >> different fonts and sizes. MeasureString only cares about a simple string
    >> of characters.
    >>
    >> --
    >> Bob Powell [MVP]
    >> Visual C#, System.Drawing
    >>
    >> Ramuseco Limited .NET consulting
    >> http://www.ramuseco.com
    >>
    >> Find great Windows Forms articles in Windows Forms Tips and Tricks
    >> http://www.bobpowell.net/tipstricks.htm
    >>
    >> Answer those GDI+ questions with the GDI+ FAQ
    >> http://www.bobpowell.net/faqmain.htm
    >>
    >> All new articles provide code in C# and VB.NET.
    >> Subscribe to the RSS feeds provided and never miss a new article.
    >>
    >>
    >>
    >>
    >>
    >>>
    >>>

    >




+ Reply to Thread

Similar Threads

  1. How to Measure frequency of less than 300 Hz
    By Application Development in forum labview
    Replies: 1
    Last Post: 12-08-2007, 05:40 PM
  2. FAQ 8.17 How can I measure time under a second?
    By Application Development in forum Perl
    Replies: 0
    Last Post: 08-30-2007, 02:03 AM
  3. Replies: 1
    Last Post: 08-27-2007, 01:31 AM
  4. measure tool
    By Application Development in forum Adobe illustrator
    Replies: 0
    Last Post: 01-15-2007, 08:00 AM
  5. Measure properties
    By Application Development in forum XML SOAP
    Replies: 2
    Last Post: 01-13-2006, 03:08 AM