This is a migrated thread and some comments may be shown as answers.

Inserting an image into richtextbox table

1 Answer 185 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
GM
Top achievements
Rank 1
GM asked on 08 Dec 2011, 02:47 PM
Hi,

I looked at the documentation article:
http://www.telerik.com/help/winforms/richtextbox-features-document-elements-tables.html
to get started.

I am battling to place an image into a cell.

To insert an image into the richtextbox is used:           
Dim i1 As New Bitmap(fullfilepathtopicture) 'where fullfilepathtopicture is already a string of the full path and filename
Me.RadRichTextBox1.InsertImage(i1)

Now if I want to insert an image and text into a picture in a table as follows I am battling:

It should look something like the attachment

Any help would be welcome.

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 12 Dec 2011, 05:47 PM
Hi Gm,

You can use the ImageInline object to insert an image in RadRichTextBox. Please consider the following code snippet. It creates a table with the required layout and inserts an image in its first cell:
Section section = new Section();
Table table = new Table();
 
TableRow row1 = new TableRow();
TableCell cell1 = new TableCell();
Paragraph p1 = new Paragraph();
 
ImageInline img1 = new ImageInline(Resources._new);
p1.Inlines.Add(img1);
             
Span s1 = new Span();
s1.Text = "Cell 1";
p1.Inlines.Add(s1);
cell1.Blocks.Add(p1);
row1.Cells.Add(cell1);
 
TableCell cell2 = new TableCell();
cell2.RowSpan = 2;
Paragraph p2 = new Paragraph();
Span s2 = new Span();
s2.Text = "Cell 2";
p2.Inlines.Add(s2);
cell2.Blocks.Add(p2);
row1.Cells.Add(cell2);
             
table.Rows.Add(row1);
 
TableRow row2 = new TableRow();
TableCell cell3 = new TableCell();
Paragraph p3 = new Paragraph();
Span s3 = new Span();
s3.Text = "Cell 3";
p3.Inlines.Add(s3);
cell3.Blocks.Add(p3);
row2.Cells.Add(cell3);
             
table.Rows.Add(row2);
 
section.Blocks.Add(table);
             
this.radRichTextBox1.Document.Sections.Add(section);

I hope it helps.
 
Best wishes,
Jack
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
GM
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or