title: RichTextBox does not display all data when I override CreateParams
body: <p>I <a href="http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/194f563c-205f-41a1-9582-4f03fd3a53c2/" rel="nofollow noreferrer">found</a> some old code written by NoBugz (<a href="https://stackoverflow.com/users/17034/hans-passant">Hans Passant</a>) which, if I understand, forces the richtextbox to use RTF 5.0 instead of 4.0.  Basically it's just a class which inherits <code>RichTextBox</code> and overrides the <code>CreateParams</code> property as such</p>
  
  <pre><code>private static IntPtr moduleHandle;
  
  [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
  static extern IntPtr LoadLibrary(string lpFileName);
  
  protected override CreateParams CreateParams
  {
      get
      {
          if (moduleHandle == IntPtr.Zero)
          {
              moduleHandle = LoadLibrary("msftedit.dll");
              if ((long)moduleHandle &lt; 0x20) throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not load Msftedit.dll");
          }
          CreateParams createParams = base.CreateParams;
          createParams.ClassName = "RichEdit50W";
          if (this.Multiline)
          {
              if (((this.ScrollBars &amp; RichTextBoxScrollBars.Horizontal) != RichTextBoxScrollBars.None) &amp;&amp; !base.WordWrap)
              {
                  createParams.Style |= 0x100000;
                  if ((this.ScrollBars &amp; ((RichTextBoxScrollBars)0x10)) != RichTextBoxScrollBars.None)
                  {
                      createParams.Style |= 0x2000;
                  }
              }
              if ((this.ScrollBars &amp; RichTextBoxScrollBars.Vertical) != RichTextBoxScrollBars.None)
              {
                  createParams.Style |= 0x200000;
                  if ((this.ScrollBars &amp; ((RichTextBoxScrollBars)0x10)) != RichTextBoxScrollBars.None)
                  {
                      createParams.Style |= 0x2000;
                  }
               }
          }
          if ((BorderStyle.FixedSingle == base.BorderStyle) &amp;&amp; ((createParams.Style &amp; 0x800000) != 0))
          {
              createParams.Style &amp;= -8388609;
              createParams.ExStyle |= 0x200;
          }
          return createParams;
      }
  }
  </code></pre>
  
  <p>When I do perform this override, I cannot get my RTF to display past the first line.  e.g.</p>
  
  <pre><code>string rtf = @"{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}{\f1 Courier New;}}\viewkind4\uc1\pard\lang1033\f0\fs20 {\pard\f0\ul\b Activated Partial Thromboplastin Time\b0 : Collected: "
                   + @"8/21/2012 4:15:00 AM\ulnon\f0\par}\par\pard\lang1033\f0\fs20 {\trowd"
                   + @"\trql\trgaph100\trrh280\trleft0\intbl"
                   + @"\cellx4000"
                   + @"\cellx9500"
                   + @"Activated Partial Thromboplastin Time\cell"
                   + @"36.8 Seconds\cell"
                   + @"\intbl\row}";
  CustomRtb cRtb = new CustomRtb();
  cRtb.Rtf = rtf;//Only the first line shows in the form...
  </code></pre>
  
  <p>Is the new standard just much less forgiving of Rtf errors or what?  I need the prettier table formatting offered by 5.0</p>
  
  <p><strong>UPDATE</strong><br />
  The data displays if I change </p>
  
  <p><code>+ @"\trql\trgaph100\trrh280\trleft0\intbl"</code></p>
  
  <p>to</p>
  
  <p><code>+ @"\trql\trgaph100\trrh280\trleft0"</code></p>
  
  <hr>
  
  <p>Upon further testing I found that the RTF looks good in MS Word.  In fact, our code generates the RTF with MsftEdit as indicated here:</p>
  
  <p><code>{\*\generator Msftedit 5.41.21.2510;}</code>.  I open up the actual RTF in Word and it looks fine.  I use this code and it pretty much matches what I see in word.  I just need to remove some borders.  I'm going to have to do some deeper digging to see why Msftedit is generating the RTF to be slightly mal-aligned in the tables.  But yea, overall this question is just getting beyond the scope of what I can do in SO.</p>