Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Format and align data in RichTextBox

Format and align data in RichTextBox

Scheduled Pinned Locked Moved C#
tutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spankyleo123
    wrote on last edited by
    #1

    Hi, Can any1 please tell me how to align and format the data appearing in the rtb. I am basically displaying rows in the rtb. Is there any way where in I can have column headers and boundaries like cells in the RTB. Please suggest... Thanks

    L 1 Reply Last reply
    0
    • S spankyleo123

      Hi, Can any1 please tell me how to align and format the data appearing in the rtb. I am basically displaying rows in the rtb. Is there any way where in I can have column headers and boundaries like cells in the RTB. Please suggest... Thanks

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, AFAIK you can have a real table in RTF files and RTB controls. "All" it takes is this: - create a table in Word - save as RTF file - look at its content, and put something similar into the RichTextBox.Rtf property. I'm not pretending editing a table through an RTB would be easy! :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


      S 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, AFAIK you can have a real table in RTF files and RTB controls. "All" it takes is this: - create a table in Word - save as RTF file - look at its content, and put something similar into the RichTextBox.Rtf property. I'm not pretending editing a table through an RTB would be easy! :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        S Offline
        S Offline
        spankyleo123
        wrote on last edited by
        #3

        Hi, do u mean to say, I create a Table structure with column headers pertaining to the rows in rtf and save it on the desktop. And then use the rtb.rtf property ? But how do I set the rtb.rtf property to the correct path of the rtf file stored in the desktop./?

        L 1 Reply Last reply
        0
        • S spankyleo123

          Hi, do u mean to say, I create a Table structure with column headers pertaining to the rows in rtf and save it on the desktop. And then use the rtb.rtf property ? But how do I set the rtb.rtf property to the correct path of the rtf file stored in the desktop./?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          No. I didn't say desktop, nor path. All I said is test with Word->RTF file->RTF property. Use some dumb editor (NotePad) to get the RTF file content and assign it to RTB.Rtf property. Look at the RTF code, modify it as needed. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          S 1 Reply Last reply
          0
          • L Luc Pattyn

            No. I didn't say desktop, nor path. All I said is test with Word->RTF file->RTF property. Use some dumb editor (NotePad) to get the RTF file content and assign it to RTB.Rtf property. Look at the RTF code, modify it as needed. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            S Offline
            S Offline
            spankyleo123
            wrote on last edited by
            #5

            Thanks sir, But i have never done this, can you please send me some web links or code snippets to achieve this task..

            L 1 Reply Last reply
            0
            • S spankyleo123

              Thanks sir, But i have never done this, can you please send me some web links or code snippets to achieve this task..

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              all it takes is a single statement, give this a try:

              this.richTextBox1.Rtf=
              @"{\rtf1\ansi\deff0{\fonttbl{\f0\froman Arial;}{\f1\froman\fcharset0 Arial;}{\f2\fswiss\fcharset0 Arial;}}"+
              @"{\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;}"+
              @"{\*\generator Msftedit 5.41.21.2507;}\viewkind4\uc1\pard\sb60\sa40\cf1\highlight2\lang1033\b\f0\fs28 Ontvangsten in Jul-2009\b0\par"+
              @"\fs20\par"+
              @"\trowd\trgaph70\trbrdrl\brdrs\brdrw15\brdrcf3 \trbrdrt\brdrs\brdrw15\brdrcf3 \trbrdrr\brdrs\brdrw15\brdrcf3 \trbrdrb\brdrs\brdrw15"+
              @"\brdrcf3 \trpaddl70\trpaddr70\trpaddfl3\trpaddfr3"+
              @"\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3"+
              @"\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx1900\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3"+
              @"\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx3400\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3"+
              @"\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx4900\clcfpat3\clcbpat3\clshdng10000"+
              @"\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx6700"+
              @"\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15"+
              @"\brdrs\brdrcf3 \cellx8200\pard\intbl\sb60\sa40\qc\cf2\highlight3\b datum\b0\cell\b contant\b0\cell\b Bancontact\b0\cell\b overschrijvingen\b0"+
              @"\cell\b totaal\b0\cell\row\trowd\trgaph70\trbrdrl\brdrs\brdrw15\brdrcf3 \trbrdrt\brdrs\brdrw15\brdrcf3 \trbrdrr\brdrs\brdrw15\brdrcf3 \trbrdrb"+
              @"\brdrs\brdrw15\brdrcf3 \trpaddl70\trpaddr70\trpaddfl3\trpaddfr3"+
              @"\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 "+
              @"\cellx1900\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs"+
              @"\brdrcf3 \cellx3400\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15"+
              @"\brdrs\brdrcf3 \cellx4900\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb"+
              @"\brdrw15\brdrs\brdrcf3 \cellx6700\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3"+
              @"\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx8200\pard\intbl\sb60\sa40\qr\cf1\highlight2 WO

              _ 1 Reply Last reply
              0
              • L Luc Pattyn

                all it takes is a single statement, give this a try:

                this.richTextBox1.Rtf=
                @"{\rtf1\ansi\deff0{\fonttbl{\f0\froman Arial;}{\f1\froman\fcharset0 Arial;}{\f2\fswiss\fcharset0 Arial;}}"+
                @"{\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;}"+
                @"{\*\generator Msftedit 5.41.21.2507;}\viewkind4\uc1\pard\sb60\sa40\cf1\highlight2\lang1033\b\f0\fs28 Ontvangsten in Jul-2009\b0\par"+
                @"\fs20\par"+
                @"\trowd\trgaph70\trbrdrl\brdrs\brdrw15\brdrcf3 \trbrdrt\brdrs\brdrw15\brdrcf3 \trbrdrr\brdrs\brdrw15\brdrcf3 \trbrdrb\brdrs\brdrw15"+
                @"\brdrcf3 \trpaddl70\trpaddr70\trpaddfl3\trpaddfr3"+
                @"\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3"+
                @"\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx1900\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3"+
                @"\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx3400\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3"+
                @"\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx4900\clcfpat3\clcbpat3\clshdng10000"+
                @"\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx6700"+
                @"\clcfpat3\clcbpat3\clshdng10000\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15"+
                @"\brdrs\brdrcf3 \cellx8200\pard\intbl\sb60\sa40\qc\cf2\highlight3\b datum\b0\cell\b contant\b0\cell\b Bancontact\b0\cell\b overschrijvingen\b0"+
                @"\cell\b totaal\b0\cell\row\trowd\trgaph70\trbrdrl\brdrs\brdrw15\brdrcf3 \trbrdrt\brdrs\brdrw15\brdrcf3 \trbrdrr\brdrs\brdrw15\brdrcf3 \trbrdrb"+
                @"\brdrs\brdrw15\brdrcf3 \trpaddl70\trpaddr70\trpaddfl3\trpaddfr3"+
                @"\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs\brdrcf3 "+
                @"\cellx1900\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15\brdrs"+
                @"\brdrcf3 \cellx3400\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb\brdrw15"+
                @"\brdrs\brdrcf3 \cellx4900\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3\clbrdrb"+
                @"\brdrw15\brdrs\brdrcf3 \cellx6700\clbrdrl\brdrw15\brdrs\brdrcf3\clbrdrt\brdrw15\brdrs\brdrcf3\clbrdrr\brdrw15\brdrs\brdrcf3"+
                @"\clbrdrb\brdrw15\brdrs\brdrcf3 \cellx8200\pard\intbl\sb60\sa40\qr\cf1\highlight2 WO

                _ Offline
                _ Offline
                _groo_
                wrote on last edited by
                #7

                Your example is using spaces to "indent" the cell contents to make them appear aligned. From what I've seen so far, it looks like RTB (at least the .Net wrapper) ignores horizontal alignment in table cells.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups