Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
1.36/5 (4 votes)
See more:
I want to create a table in RichTextBox as we create the table in MS Word document. I am working on a C# apllication and want to dislay a well structured format in the RichTextBox. Please help.
Posted
Updated 21-Mar-17 7:46am
v2

1 solution

You can do it by directly setting the RTF. Here's a sample that should give you some idea what you want to do:
{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Microsoft Arial;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\trowd\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10\brdrcf1 \trbrdrl\brdrs\brdrw10\brdrcf1 \trbrdrb\brdrs\brdrw10\brdrcf1 \trbrdrr\brdrs\brdrw10\brdrcf1 \clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx1576\clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx3260\clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx4944\pard\intbl\ltrpar\sl276\slmult1\f0\fs22 TopLeft\Top Right\cell\row
\trowd\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10\brdrcf1 \trbrdrl\brdrs\brdrw10\brdrcf1 \trbrdrb\brdrs\brdrw10\brdrcf1 \trbrdrr\brdrs\brdrw10\brdrcf1 \clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx1576\clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx3260\clbrdrt\brdrw15\brdrs\clbrdrl\brdrw15\brdrs\clbrdrb\brdrw15\brdrs\clbrdrr\brdrw15\brdrs \cellx4944\intbl Bottom Left\cell Bottom Right\cell\row
\pard\ltrpar\sa200\sl276\slmult1\par
\pard\ltrpar\f1\fs17\par
}
You should really read up on the RTF format if you want to do this. Alternatively (and here's a handy hint), create the page you want in Word, and save it out as an RTF file. You can use this as the basis of creating your application.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900