tommy.carlier
11/30/2004 7:41:00 AM
Steve Bugden <SteveBugden@discussions.microsoft.com> wrote in message news:<E25590D1-4E71-47D2-B8C0-04441ABFFDFC@microsoft.com>...
> Hi,
>
> I'm just wondering if it is possible to create an image from RTF formatted
> text?
>
> If it isn't possible, is there anyway of determining the height of an rtf
> string for a given width? I have the text in a richtextbox control and would
> like to set the height so that all of the text is displayed.
>
> Thanks,
>
> Steve.
I don't know how to create an image from RTF, but I do know how to get
the height for a given width. The RichTextBox control has an event
ContentsResized, that is called when the size of the content changes.
The event has an argument of type ContentsResizedEventArgs, that has a
property NewRectangle of type rectangle.
// myRTB is the RichTextBox
myRTB.ContentsResized += new
ContentsResizedEventHandler(myRTB_ContentsResized);
private void myRTB_ContentsResized(object sender,
ContentsResizedEventArgs e)
{
int height = e.NewRectangle.Height; // the new height
}