Inserting an image into richtextbox table

2 posts, 0 answers
  1. GM
    GM avatar
    6 posts
    Member since:
    Jul 2011

    Posted 08 Dec 2011 Link to this post

    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.
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 12 Dec 2011 Link to this post

    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.

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top