Controls inside RichTextBox

  • Thread starter Thread starter Adam Nowotny
  • Start date Start date
A

Adam Nowotny

I have a RichTextBox component that i use to display some formated text.
It turned out, that i also need to display tables in it. I thought about displaying it using some
Grid component. So i created it and added using

Me.RichTextBox1.Controls.Add(MyNewGridControl)

It displays...but it seems to be "outside" of the RichTextBox content. I want it be "anchored" in
the text, so i can scroll everything - as in Word document or IE window.
How to accomplish this ?
Or is there any component, that i can use to display text with pictures, tables ?
 
Hi Adam,

To my understanding you need insert some tables and pictures into a
RichTextBox like Word?
If my understanding is correct, I'm afraid DataGrid could not help you in
this case. The context inside the RichTextBox is formatted by the RichText
Format Specification, the table is actually described by a set of tags. So
if you need add tables and pictures into a RichTextBox, you need manuplate
the tags by yourself.
Here is an article on CodeProject which inserts the RTF tags to add Texts
and Images into the RichTextBox,
<Insert Plain Text and Images into RichTextBox at Runtime>
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp
For more information on RTF Spec. You may refer to
<Rich Text Format (RTF) Specification, version 1.6>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/h
tml/rtfspec.asp

Please feel free to reply this thread, if you have anything unclear about
it.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Ying-Shen Yu said:
Hi Adam,

To my understanding you need insert some tables and pictures into a
RichTextBox like Word?

Exacly :]
If my understanding is correct, I'm afraid DataGrid could not help you in
this case. The context inside the RichTextBox is formatted by the RichText
Format Specification, the table is actually described by a set of tags. So
if you need add tables and pictures into a RichTextBox, you need manuplate
the tags by yourself.
Here is an article on CodeProject which inserts the RTF tags to add Texts
and Images into the RichTextBox,
<Insert Plain Text and Images into RichTextBox at Runtime>
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp
For more information on RTF Spec. You may refer to
<Rich Text Format (RTF) Specification, version 1.6>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/h
tml/rtfspec.asp

Looks like a lot of work to me, say good-bye to code reusing.
But what if it turns out (customers are unpredictable :], it will come surely, probably sooner than
later) i need some more sophisticated like links or clickable icons (user clicks on it and it does
something like displaying a new window with a picture, or maybe activating some other module of
application etc.).
So the problem arises, when i need some interaction with the user.
I imagine the best solution would be a component with scrollable content and the oportunity to add
any other .NET component to it. Right now a use axWebBrowser for rendering the content, but i don't
like the idea of using COM, and it reacts really strange under some (random hehe) circumstances.
Anyway, thanks for the links to RTF docs, i will consider using it for some parts of the system.
 
Back
Top