how to add text in a created table in a richtextbox?

Posted by francops henri on Stack Overflow See other posts from Stack Overflow or by francops henri
Published on 2012-09-24T09:35:55Z Indexed on 2012/09/24 9:37 UTC
Read the original article Hit count: 223

Filed under:
|
|

I created a table in richtextbox like this :

                  //Since too much string appending go for string builder
       StringBuilder tableRtf = new StringBuilder();

       //beginning of rich text format,dont customize this begining line              
    tableRtf.Append(@"{\rtf1 ");             

    //create 5 rows with 3 cells each

        for (int i = 0; i < 5; i++)
        {

            tableRtf.Append(@"\trowd");

           //A cell with width 1000.
            tableRtf.Append(@"\cellx1000"); 

            //Another cell with width 2000.end point is 3000 (which is 1000+2000).
            tableRtf.Append(@"\cellx2000"); 

            //Another cell with width 1000.end point is 4000 (which is 3000+1000)
            tableRtf.Append(@"\cellx3000");

            //Another cell with width 1000.end point is 4000 (which is 3000+1000)
            tableRtf.Append(@"\cellx4000");


            tableRtf.Append(@"\intbl \cell \row"); //create row

        }

        tableRtf.Append(@"\pard");

        tableRtf.Append(@"}");

        this.misc_tb.Rtf = tableRtf.ToString(); 

Now I want to know how I can put text in headers and in each cells.

Do you have an idea?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about richtextbox