<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Pete's Weblog</title>
        <link>http://geekswithblogs.net/pvidler/Default.aspx</link>
        <description>The Blog Formerly Known as Fun with WinForms</description>
        <language>en-GB</language>
        <copyright>Pete Vidler</copyright>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>Pete's Weblog</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/pvidler/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Automatic Windows Update</title>
            <category>General</category>
            <link>http://geekswithblogs.net/pvidler/archive/2004/09/24/11660.aspx</link>
            <description>&lt;p&gt;Looks like my computer is doing a windows update. I didn't ask it to (I don't have automatic updates turned on), but I guess this is WinXP SP2 installing itself. I'm a bit pissed off that it didn't even tell me it was going to install something -- it just appeared as an icon in the notification area.&lt;/p&gt;

&lt;p&gt;If it suddenly pops up a dialog asking me to reset the computer (or worse, does it for me without asking), I'll be going back to Linux. Imagine getting a sudden popup asking you to reset your computer; if you didn't notice the thing installing, an inexperienced user will probably think it was a virus like blaster. The question is, would they be wrong?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The mysterious update appears to have stopped downloading at 47%. There is no internet activity. There appears to be no way to cancel or restart the download (no context menu, nothing happens when I double-click it). I will have to wait a while then try to end the process, I guess. How is an ordinary, non-technical user supposed to deal with this?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second Update:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Okay, I ended the process. The icon disappeared and then immediately reappeared. That's cheating! On the plus side, it now seems to be at 48% (and it's only been two hours to get that extra 1%).&lt;/p&gt;

&lt;p&gt;What is really getting on my nerves is that I'm moving tomorrow. This computer probably won't touch the internet again for a long time (possibly years, as I will be using computers at uni). I really needed to spend this time downloading the programs and websites that I will need so they can be used offline, and not worrying about whether this weird update will go away or not.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=11660"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=11660" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/11660.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2004/09/24/11660.aspx</guid>
            <pubDate>Fri, 24 Sep 2004 16:47:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/11660.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2004/09/24/11660.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/11660.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/11660.aspx</trackback:ping>
        </item>
        <item>
            <title>Extending RichTextBox - Part III</title>
            <category>Windows Forms</category>
            <link>http://geekswithblogs.net/pvidler/archive/2003/10/15/192.aspx</link>
            <description>&lt;p&gt;As promised earlier, I've added the ability to change the background colour of the text. I've also made one or two minor changes to the rest of the code, which I'll detail at the end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Background Colour&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Changing the background colour is a simple matter. It works in exactly the same way as changing the underline style, by setting the character format. Since we're dealing with Color here, we need to be using System.Drawing. Then it's just a matter of sending the correct message:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost3Div1');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Code to set the background colour for a selected region.
&lt;/div&gt;

&lt;div id="pvidlerCodePost3Div1" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Gets or sets the background color to apply to the&lt;/span&gt;
&lt;span style="color: green;"&gt;/// current selection or insertion point.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// If the selection contains more than one background&lt;/span&gt;
&lt;span style="color: green;"&gt;/// color, then this property will indicate it by&lt;/span&gt;
&lt;span style="color: green;"&gt;/// returning Color.Empty.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;Color&lt;/span&gt; &lt;span style="color: red;"&gt;SelectionBackColor&lt;/span&gt;
{
    &lt;span style="color: blue;"&gt;get&lt;/span&gt;
    {
        &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Get the background color.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ), &lt;span style="color: #6c6c6c;"&gt;EM_GETCHARFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Default to Color.Empty as there could be&lt;/span&gt;
        &lt;span style="color: green;"&gt;// several colors present in this selection.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( ( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; &amp;amp; &lt;span style="color: #6c6c6c;"&gt;CFM_BACKCOLOR&lt;/span&gt; ) == 0 )
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: firebrick;"&gt;Color&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;Empty&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Deal with the weird Windows color format.&lt;/span&gt;
        &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;backCol&lt;/span&gt; = &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;crBackColor&lt;/span&gt;;
        &lt;span style="color: firebrick;"&gt;Color&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;ret&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;ColorTranslator&lt;/span&gt;.&lt;span style="color: red;"&gt;FromWin32&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;backCol&lt;/span&gt; );
        
        &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;ret&lt;/span&gt;;
    }
    
    &lt;span style="color: blue;"&gt;set&lt;/span&gt;
    {
        &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; = &lt;span style="color: #6c6c6c;"&gt;CFM_BACKCOLOR&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Deal with the weird Windows color format.&lt;/span&gt;
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;crBackColor&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;ColorTranslator&lt;/span&gt;.&lt;span style="color: red;"&gt;ToWin32&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Set the background color.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ), &lt;span style="color: #6c6c6c;"&gt;EM_SETCHARFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
    }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;And there's one more constant to add:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;CFM_BACKCOLOR&lt;/span&gt; = 67108864;
&lt;/pre&gt;&lt;/code&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;That should now enable us to change the background colour of the text. Simple, wasn't it?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alterations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Notice in the middle of the get method above, we return &lt;code&gt;Color.Empty&lt;/code&gt; by default. This is because that return value is used when more than one colour is selected (like in Word when you select across several fonts and the font selection combobox goes blank). A similar approach can be taken in the alignment and underline properties presented previously.&lt;/p&gt;

&lt;p&gt;All you have to do is add an entry to the relevant enumeration called "None" (or whatever), probably equal to zero, and return it in the appropriate get method where it says "Default to &amp;lt;whatever&amp;gt;".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it for &lt;code&gt;AdvRichTextBox&lt;/code&gt;. If anyone is actually reading this and wants me to add more functionality (or post complete source), just leave a comment or send me an email.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=192"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=192" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/192.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2003/10/15/192.aspx</guid>
            <pubDate>Thu, 16 Oct 2003 00:33:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/192.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2003/10/15/192.aspx#feedback</comments>
            <slash:comments>30</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/192.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/192.aspx</trackback:ping>
        </item>
        <item>
            <title>Extending RichTextBox - Part II</title>
            <category>Windows Forms</category>
            <link>http://geekswithblogs.net/pvidler/archive/2003/10/15/188.aspx</link>
            <description>&lt;p&gt;Microsoft Word and Visual Studio have one very cool feature in common -- squiggly underlining of errors. As of richedit 3.0 (distributed with Windows 2000 and higher, possibly also with ME) we can get these in the &lt;code&gt;RichTextBox&lt;/code&gt;. Actually, we can get a lot more underline styles than that...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Underlining&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once again we are going to have to communicate with the underlying richedit control. This time we need to set the character format, so we'll need to add some extra stuff to our class:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost2Div1');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Code to interface with the Win32 &lt;code&gt;CHARFORMAT2&lt;/code&gt; structure.
&lt;/div&gt;

&lt;div id="pvidlerCodePost2Div1" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;CFM_UNDERLINETYPE&lt;/span&gt; = 8388608;
&lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;EM_SETCHARFORMAT&lt;/span&gt; = 1092;
&lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;EM_GETCHARFORMAT&lt;/span&gt; = 1082;

[StructLayout( LayoutKind.Sequential )]
&lt;span style="color: blue;"&gt;private struct&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;
{
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;uint&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;uint&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dwEffects&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;yHeight&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;yOffset&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;crTextColor&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bCharSet&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bPitchAndFamily&lt;/span&gt;;
    [MarshalAs( UnmanagedType.ByValArray, SizeConst = 32 )]
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;char&lt;/span&gt;[] &lt;span style="color: #6c6c6c;"&gt;szFaceName&lt;/span&gt;;
    
    &lt;span style="color: green;"&gt;// CHARFORMAT2 from here onwards.&lt;/span&gt;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wWeight&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;sSpacing&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;crBackColor&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;LCID&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;uint&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dwReserved&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;sStyle&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wKerning&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bUnderlineType&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bAnimation&lt;/span&gt;;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bRevAuthor&lt;/span&gt;;
}

[DllImport( "user32", CharSet = CharSet.Auto )]
&lt;span style="color: blue;"&gt;private static extern&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;hWnd&lt;/span&gt;, &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;msg&lt;/span&gt;,
                                       &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wParam&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;lp&lt;/span&gt; );
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;&lt;strong&gt;Underline Style&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The underline style and colour are both set with the same message, so we must be careful to preserve the colour while changing the underline style. We'll use a property again so that we remain consistent with the original &lt;code&gt;RichTextBox&lt;/code&gt;:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost2Div2');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Code to set the underline style.
&lt;/div&gt;

&lt;div id="pvidlerCodePost2Div2" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Gets or sets the underline style to apply to the&lt;/span&gt;
&lt;span style="color: green;"&gt;/// current selection or insertion point.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Underline styles can be set to any value of the&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="UnderlineStyle"/&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;enumeration.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt; &lt;span style="color: red;"&gt;SelectionUnderlineStyle&lt;/span&gt;
{
    &lt;span style="color: blue;"&gt;get&lt;/span&gt;
    {
        &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Get the underline style.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ), &lt;span style="color: #6c6c6c;"&gt;EM_GETCHARFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Default to no underline.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( ( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; &amp;amp; &lt;span style="color: #6c6c6c;"&gt;CFM_UNDERLINETYPE&lt;/span&gt; ) == 0 )
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;None&lt;/span&gt;;
        
        &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt; = ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;bUnderlineType&lt;/span&gt; &amp;amp; 0x0F );
        
        &lt;span style="color: blue;"&gt;return&lt;/span&gt; ( &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt;;
    }
    
    &lt;span style="color: blue;"&gt;set&lt;/span&gt;
    {
        &lt;span style="color: green;"&gt;// Ensure we don't alter the color by accident.&lt;/span&gt;
        &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;color&lt;/span&gt; = &lt;span style="color: red;"&gt;SelectionUnderlineColor&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Ensure we don't show it if it shouldn't be shown.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( &lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt; == &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;None&lt;/span&gt; )
            &lt;span style="color: #6c6c6c;"&gt;color&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;Black&lt;/span&gt;;
        
        &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; = &lt;span style="color: #6c6c6c;"&gt;CFM_UNDERLINETYPE&lt;/span&gt;;
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;bUnderlineType&lt;/span&gt; = ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )( ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt; | ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;color&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Set the underline type.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ), &lt;span style="color: #6c6c6c;"&gt;EM_SETCHARFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
    }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;Once again, this has not been fully tested so you use it at your own risk. Let me know if there are any problems, etc. The &lt;code&gt;UnderlineStyle&lt;/code&gt; enumeration is also fairly straightforward:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost2Div3');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  &lt;code&gt;UnderlineStyle&lt;/code&gt; enumeration.
&lt;/div&gt;

&lt;div id="pvidlerCodePost2Div3" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Specifies the style of underline that should be&lt;/span&gt;
&lt;span style="color: green;"&gt;/// applied to the text.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public enum&lt;/span&gt; &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt;
{
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// No underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;None&lt;/span&gt; = 0,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Standard underlining across all words.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Normal&lt;/span&gt; = 1,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Standard underlining broken between words.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Word&lt;/span&gt; = 2,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Double line underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Double&lt;/span&gt; = 3,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Dotted underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Dotted&lt;/span&gt; = 4,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Dashed underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Dash&lt;/span&gt; = 5,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Dash-dot ("-.-.") underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DashDot&lt;/span&gt; = 6,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Dash-dot-dot ("-..-..") underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DashDotDot&lt;/span&gt; = 7,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Wave underlining (like spelling mistakes in MS Word).&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Wave&lt;/span&gt; = 8,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Extra thick standard underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Thick&lt;/span&gt; = 9,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Extra thin standard underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;HairLine&lt;/span&gt; = 10,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Double thickness wave underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DoubleWave&lt;/span&gt; = 11,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Thick wave underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;HeavyWave&lt;/span&gt; = 12,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Extra long dash underlining.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;LongDash&lt;/span&gt; = 13
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;Note that some of these styles may not display correctly. This is a common problem with the richedit control, often you will apply some formatting only to find that it will not display at all. The formatting is usually stored though, so cutting and pasting into Word will show the text correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Underline Colour&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can also change the underline colour. Notice how the set method of underline colour retrieves the underline style in order to maintain consistency.&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost2Div4');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Code to set the underline colour.
&lt;/div&gt;

&lt;div id="pvidlerCodePost2Div4" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Gets or sets the underline color to apply to the&lt;/span&gt;
&lt;span style="color: green;"&gt;/// current selection or insertion point.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Underline colors can be set to any value of the&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="UnderlineColor"/&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;enumeration.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt; &lt;span style="color: red;"&gt;SelectionUnderlineColor&lt;/span&gt;
{
    &lt;span style="color: blue;"&gt;get&lt;/span&gt;
    {
        &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Get the underline color.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ), &lt;span style="color: #6c6c6c;"&gt;EM_GETCHARFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Default to black.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( ( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; &amp;amp; &lt;span style="color: #6c6c6c;"&gt;CFM_UNDERLINETYPE&lt;/span&gt; ) == 0 )
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;Black&lt;/span&gt;;
        
        &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt; = ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;bUnderlineType&lt;/span&gt; &amp;amp; 0xF0 );
        
        &lt;span style="color: blue;"&gt;return&lt;/span&gt; ( &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt;;
    }
    
    &lt;span style="color: blue;"&gt;set&lt;/span&gt;
    {
        &lt;span style="color: green;"&gt;// Ensure we don't alter the style.&lt;/span&gt;
        &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt; = &lt;span style="color: red;"&gt;SelectionUnderlineStyle&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Ensure we don't show it if it shouldn't be shown.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( &lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt; == &lt;span style="color: firebrick;"&gt;UnderlineStyle&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;None&lt;/span&gt; )
            &lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;Black&lt;/span&gt;;
        
        &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;CHARFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; = &lt;span style="color: #6c6c6c;"&gt;CFM_UNDERLINETYPE&lt;/span&gt;;
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;bUnderlineType&lt;/span&gt; = ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )( ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;style&lt;/span&gt; | ( &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Set the underline color.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ), &lt;span style="color: #6c6c6c;"&gt;EM_SETCHARFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
    }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;Unfortunately there are not many colours available to this property. They are defined by the &lt;code&gt;UnderlineColor&lt;/code&gt; enumeration:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost2Div5');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  &lt;code&gt;UnderlineColor&lt;/code&gt; enumeration.
&lt;/div&gt;

&lt;div id="pvidlerCodePost2Div5" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Specifies the color of underline that should be&lt;/span&gt;
&lt;span style="color: green;"&gt;/// applied to the text.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// I named these colors by their appearance, so some&lt;/span&gt;
&lt;span style="color: green;"&gt;/// of them might not be what you expect. Please email&lt;/span&gt;
&lt;span style="color: green;"&gt;/// me if you feel one should be changed.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public enum&lt;/span&gt; &lt;span style="color: firebrick;"&gt;UnderlineColor&lt;/span&gt;
{
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Black.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Black&lt;/span&gt; = 0x00,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Blue.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Blue&lt;/span&gt; = 0x10,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Cyan.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Cyan&lt;/span&gt; = 0x20,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Lime green.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;LimeGreen&lt;/span&gt; = 0x30,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Magenta.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Magenta&lt;/span&gt; = 0x40,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Red.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Red&lt;/span&gt; = 0x50,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Yellow.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Yellow&lt;/span&gt; = 0x60,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;White.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;White&lt;/span&gt; = 0x70,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;DarkBlue.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DarkBlue&lt;/span&gt; = 0x80,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;DarkCyan.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DarkCyan&lt;/span&gt; = 0x90,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Green.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Green&lt;/span&gt; = 0xA0,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Dark magenta.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DarkMagenta&lt;/span&gt; = 0xB0,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Brown.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Brown&lt;/span&gt; = 0xC0,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Olive green.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;OliveGreen&lt;/span&gt; = 0xD0,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Dark gray.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;DarkGray&lt;/span&gt; = 0xE0,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;Gray.&lt;/span&gt;&lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Gray&lt;/span&gt; = 0xF0
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;If you set the underline colour to anything other than black it will not serialise correctly. I don't know if this is by design or not. Any text with a non-black underline that is cut and pasted into Word (or any other application) will lose it's underlining all together. I don't know if the underline is still stored in the actual rich text or not when this happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well that's it for part two. In my next post in this series I will cover setting the background colour.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=188"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=188" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/188.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2003/10/15/188.aspx</guid>
            <pubDate>Wed, 15 Oct 2003 14:19:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/188.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2003/10/15/188.aspx#feedback</comments>
            <slash:comments>19</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/188.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/188.aspx</trackback:ping>
        </item>
        <item>
            <title>Extending RichTextBox</title>
            <category>Windows Forms</category>
            <link>http://geekswithblogs.net/pvidler/archive/2003/10/14/182.aspx</link>
            <description>&lt;p&gt;For a while now I've been toying with the idea of writing a C# editor (almost an IDE, but with only the features that I need). Clearly the hardest part of this task would be getting some form of edit control working.. the obvious choice for which is the &lt;code&gt;RichTextBox&lt;/code&gt;. Anyone who has tried using &lt;code&gt;RichTextBox&lt;/code&gt; in this situation will know that it has a number of flaws, the most serious being that it's rather slow when trying to colourise the text.&lt;/p&gt;

&lt;p&gt;I've long since given up on using &lt;code&gt;RichTextBox&lt;/code&gt; for a code editor, but while I was investigating its use I came across a number of ways to improve it's functionality. I'll present these here in a series of posts on the subject.. first up is how to speed up the control's updating, as well as adding one little extra formatting option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Faster Updating&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are articles on this subject on the internet. The standard method seems to be to send a &lt;code&gt;WM_SETREDRAW&lt;/code&gt; message to prevent the control from being redrawn while updating. I had this implemented and running nicely when I came across &lt;a href="http://home.att.net/~robertdunn/Papers/FasterSyntaxHighlighting.doc"&gt;another article&lt;/a&gt; showing that an extra speed increase can be gained by sending &lt;code&gt;EM_SETEVENTMASK&lt;/code&gt; to prevent the control from handling events. Here's the code:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost1Div1');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Code to help speed up &lt;code&gt;RichTextBox&lt;/code&gt; updating.
&lt;/div&gt;

&lt;div id="pvidlerCodePost1Div1" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Maintains performance while updating.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// It is recommended to call this method before doing&lt;/span&gt;
&lt;span style="color: green;"&gt;/// any major updates that you do not wish the user to&lt;/span&gt;
&lt;span style="color: green;"&gt;/// see. Remember to call EndUpdate when you are finished&lt;/span&gt;
&lt;span style="color: green;"&gt;/// with the update. Nested calls are supported.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Calling this method will prevent redrawing. It will&lt;/span&gt;
&lt;span style="color: green;"&gt;/// also setup the event mask of the underlying richedit&lt;/span&gt;
&lt;span style="color: green;"&gt;/// control so that no events are sent.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;void&lt;/span&gt; &lt;span style="color: red;"&gt;BeginUpdate&lt;/span&gt;()
{
    &lt;span style="color: green;"&gt;// Deal with nested calls.&lt;/span&gt;
    ++&lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt;;
    
    &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( &lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt; &amp;gt; 1 )
        &lt;span style="color: blue;"&gt;return&lt;/span&gt;;
    
    &lt;span style="color: green;"&gt;// Prevent the control from raising any events.&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;oldEventMask&lt;/span&gt; = &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                                &lt;span style="color: #6c6c6c;"&gt;EM_SETEVENTMASK&lt;/span&gt;, 0, 0 );
    
    &lt;span style="color: green;"&gt;// Prevent the control from redrawing itself.&lt;/span&gt;
    &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                 &lt;span style="color: #6c6c6c;"&gt;WM_SETREDRAW&lt;/span&gt;, 0, 0 );
}

&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Resumes drawing and event handling.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// This method should be called every time a call is made&lt;/span&gt;
&lt;span style="color: green;"&gt;/// made to BeginUpdate. It resets the event mask to it's&lt;/span&gt;
&lt;span style="color: green;"&gt;/// original value and enables redrawing of the control.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;void&lt;/span&gt; &lt;span style="color: red;"&gt;EndUpdate&lt;/span&gt;()
{
    &lt;span style="color: green;"&gt;// Deal with nested calls.&lt;/span&gt;
    --&lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt;;
    
    &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( &lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt; &amp;gt; 0 )
        &lt;span style="color: blue;"&gt;return&lt;/span&gt;;
    
    &lt;span style="color: green;"&gt;// Allow the control to redraw itself.&lt;/span&gt;
    &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                 &lt;span style="color: #6c6c6c;"&gt;WM_SETREDRAW&lt;/span&gt;, 1, 0 );
    
    &lt;span style="color: green;"&gt;// Allow the control to raise event messages.&lt;/span&gt;
    &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                 &lt;span style="color: #6c6c6c;"&gt;EM_SETEVENTMASK&lt;/span&gt;, 0, &lt;span style="color: #6c6c6c;"&gt;oldEventMask&lt;/span&gt; );
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;Although I'm using &lt;code&gt;HandleRef&lt;/code&gt; here, I have absolutely no idea if this is the correct usage (or even if it's needed). Full code will be at the end of this posting. I have not fully tested these methods so I have no idea what the performance gains might be (if there are any). If anyone wants to try benchmarking, please let me know the results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Justification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It always bothered me that the &lt;code&gt;SelectionAlignment&lt;/code&gt; property of &lt;code&gt;RichTextBox&lt;/code&gt; does not allow fully justified text. Especially since I know it's possible with the richedit control that &lt;code&gt;RichTextBox&lt;/code&gt; wraps. Here's some code that will replace &lt;code&gt;SelectionAlignment&lt;/code&gt; with something a little nicer for those that are writing word processors in C#:&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost1Div2');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Code to allow justified text in the &lt;code&gt;RichTextBox&lt;/code&gt;.
&lt;/div&gt;

&lt;div id="pvidlerCodePost1Div2" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Gets or sets the alignment to apply to the current&lt;/span&gt;
&lt;span style="color: green;"&gt;/// selection or insertion point.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Replaces the SelectionAlignment from&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="RichTextBox"/&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt; &lt;span style="color: red;"&gt;SelectionAlignment&lt;/span&gt;
{
    &lt;span style="color: blue;"&gt;get&lt;/span&gt;
    {
        &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Get the alignment.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                     &lt;span style="color: #6c6c6c;"&gt;EM_GETPARAFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Default to Left align.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( ( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; &amp;amp; &lt;span style="color: #6c6c6c;"&gt;PFM_ALIGNMENT&lt;/span&gt; ) == 0 )
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;Left&lt;/span&gt;;
        
        &lt;span style="color: blue;"&gt;return&lt;/span&gt; ( &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;wAlignment&lt;/span&gt;;
    }
    
    &lt;span style="color: blue;"&gt;set&lt;/span&gt;
    {
        &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt;();
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; = &lt;span style="color: #6c6c6c;"&gt;PFM_ALIGNMENT&lt;/span&gt;;
        &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;wAlignment&lt;/span&gt; = ( &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Set the alignment.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                     &lt;span style="color: #6c6c6c;"&gt;EM_SETPARAFORMAT&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
    }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;The &lt;code&gt;TextAlign&lt;/code&gt; enumeration contains &lt;code&gt;Left&lt;/code&gt;, &lt;code&gt;Right&lt;/code&gt;, &lt;code&gt;Center&lt;/code&gt; and &lt;code&gt;Justify&lt;/code&gt;. Again, this is mostly untested -- it &lt;em&gt;should&lt;/em&gt; work on any machine with the richedit 2.0 common control (I believe), but I offer no guarantees.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's the full code for the &lt;code&gt;AdvRichTextBox&lt;/code&gt; control (plus the &lt;code&gt;TextAlign&lt;/code&gt; enumeration):&lt;/p&gt;

&lt;!-- CODE BEGINS HERE --&gt;

&lt;p&gt;&lt;div style="padding: 0.8em 0.5em; margin: 0em 2em; background-color: #ebebeb; border: 1px dashed black;"&gt;
&lt;span style="padding: 0.2em 0.5em; font-weight: bold; color: navy; background-color: silver; border: 1px solid black; cursor: pointer" onclick="var div=document.getElementById('pvidlerCodePost1Div3');
if(div.style.display=='none')
{
    div.style.display='block';
    this.innerHTML='&amp;minus;';
}
else
{
    div.style.display='none';
    this.innerHTML='+';
}"&gt;+&lt;/span&gt;  Full &lt;code&gt;AdvRichTextBox&lt;/code&gt; code.
&lt;/div&gt;

&lt;div id="pvidlerCodePost1Div3" style="display:none"&gt;
&lt;code&gt;&lt;pre style="padding: 0.5em; margin: 0em 2em; background-color: #ebebeb; border-bottom: 1px dashed black; border-left: 1px dashed black; border-right: 1px dashed black;"&gt;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: firebrick;"&gt;System&lt;/span&gt;;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: firebrick;"&gt;System&lt;/span&gt;.&lt;span style="color: firebrick;"&gt;Windows&lt;/span&gt;.&lt;span style="color: firebrick;"&gt;Forms&lt;/span&gt;;
&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: firebrick;"&gt;System&lt;/span&gt;.&lt;span style="color: firebrick;"&gt;Runtime&lt;/span&gt;.&lt;span style="color: firebrick;"&gt;InteropServices&lt;/span&gt;;

&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Represents a standard&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="RichTextBox"/&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;with some&lt;/span&gt;
&lt;span style="color: green;"&gt;/// minor added functionality.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// AdvRichTextBox provides methods to maintain performance&lt;/span&gt;
&lt;span style="color: green;"&gt;/// while it is being updated. Additional formatting features&lt;/span&gt;
&lt;span style="color: green;"&gt;/// have also been added.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public class&lt;/span&gt; &lt;span style="color: firebrick;"&gt;AdvRichTextBox&lt;/span&gt; : &lt;span style="color: firebrick;"&gt;RichTextBox&lt;/span&gt;
{
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Maintains performance while updating.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// It is recommended to call this method before doing&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// any major updates that you do not wish the user to&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// see. Remember to call EndUpdate when you are finished&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// with the update. Nested calls are supported.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Calling this method will prevent redrawing. It will&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// also setup the event mask of the underlying richedit&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// control so that no events are sent.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;void&lt;/span&gt; &lt;span style="color: red;"&gt;BeginUpdate&lt;/span&gt;()
    {
        &lt;span style="color: green;"&gt;// Deal with nested calls.&lt;/span&gt;
        ++&lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt;;
        
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( &lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt; &amp;gt; 1 )
            &lt;span style="color: blue;"&gt;return&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Prevent the control from raising any events.&lt;/span&gt;
        &lt;span style="color: #6c6c6c;"&gt;oldEventMask&lt;/span&gt; = &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                                    &lt;span style="color: #6c6c6c;"&gt;EM_SETEVENTMASK&lt;/span&gt;, 0, 0 );
        
        &lt;span style="color: green;"&gt;// Prevent the control from redrawing itself.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                     &lt;span style="color: #6c6c6c;"&gt;WM_SETREDRAW&lt;/span&gt;, 0, 0 );
    }
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Resumes drawing and event handling.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// This method should be called every time a call is made&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// made to BeginUpdate. It resets the event mask to it's&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// original value and enables redrawing of the control.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;void&lt;/span&gt; &lt;span style="color: red;"&gt;EndUpdate&lt;/span&gt;()
    {
        &lt;span style="color: green;"&gt;// Deal with nested calls.&lt;/span&gt;
        --&lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt;;
        
        &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( &lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt; &amp;gt; 0 )
            &lt;span style="color: blue;"&gt;return&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// Allow the control to redraw itself.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                     &lt;span style="color: #6c6c6c;"&gt;WM_SETREDRAW&lt;/span&gt;, 1, 0 );
        
        &lt;span style="color: green;"&gt;// Allow the control to raise event messages.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                     &lt;span style="color: #6c6c6c;"&gt;EM_SETEVENTMASK&lt;/span&gt;, 0, &lt;span style="color: #6c6c6c;"&gt;oldEventMask&lt;/span&gt; );
    }
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Gets or sets the alignment to apply to the current&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// selection or insertion point.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// Replaces the SelectionAlignment from&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="RichTextBox"/&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
    &lt;span style="color: blue;"&gt;public new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt; &lt;span style="color: red;"&gt;SelectionAlignment&lt;/span&gt;
    {
        &lt;span style="color: blue;"&gt;get&lt;/span&gt;
        {
            &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt;();
            &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
            
            &lt;span style="color: green;"&gt;// Get the alignment.&lt;/span&gt;
            &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                         &lt;span style="color: #6c6c6c;"&gt;EM_GETPARAFORMAT&lt;/span&gt;,
                         &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
            
            &lt;span style="color: green;"&gt;// Default to Left align.&lt;/span&gt;
            &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( ( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; &amp;amp; &lt;span style="color: #6c6c6c;"&gt;PFM_ALIGNMENT&lt;/span&gt; ) == 0 )
                &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;Left&lt;/span&gt;;
            
            &lt;span style="color: blue;"&gt;return&lt;/span&gt; ( &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;wAlignment&lt;/span&gt;;
        }
        
        &lt;span style="color: blue;"&gt;set&lt;/span&gt;
        {
            &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt;();
            &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt; = &lt;span style="color: firebrick;"&gt;Marshal&lt;/span&gt;.&lt;span style="color: red;"&gt;SizeOf&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
            &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt; = &lt;span style="color: #6c6c6c;"&gt;PFM_ALIGNMENT&lt;/span&gt;;
            &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt;.&lt;span style="color: #6c6c6c;"&gt;wAlignment&lt;/span&gt; = ( &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; )&lt;span style="color: #6c6c6c;"&gt;value&lt;/span&gt;;
            
            &lt;span style="color: green;"&gt;// Set the alignment.&lt;/span&gt;
            &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                         &lt;span style="color: #6c6c6c;"&gt;EM_SETPARAFORMAT&lt;/span&gt;,
                         &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt;, &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;fmt&lt;/span&gt; );
        }
    }
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// This member overrides&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="Control"/&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;.OnHandleCreated.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: blue;"&gt;protected override&lt;/span&gt; &lt;span style="color: firebrick;"&gt;void&lt;/span&gt; &lt;span style="color: red;"&gt;OnHandleCreated&lt;/span&gt;( &lt;span style="color: firebrick;"&gt;EventArgs&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;e&lt;/span&gt; )
    {
        &lt;span style="color: #6c6c6c;"&gt;base&lt;/span&gt;.&lt;span style="color: red;"&gt;OnHandleCreated&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;e&lt;/span&gt; );
        
        &lt;span style="color: green;"&gt;// Enable support for justification.&lt;/span&gt;
        &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt;( &lt;span style="color: #6c6c6c;"&gt;this&lt;/span&gt;, &lt;span style="color: red;"&gt;Handle&lt;/span&gt; ),
                     &lt;span style="color: #6c6c6c;"&gt;EM_SETTYPOGRAPHYOPTIONS&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;TO_ADVANCEDTYPOGRAPHY&lt;/span&gt;,
                     &lt;span style="color: #6c6c6c;"&gt;TO_ADVANCEDTYPOGRAPHY&lt;/span&gt; );
    }
    
    &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;updating&lt;/span&gt; = 0;
    &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;oldEventMask&lt;/span&gt; = 0;
    
    &lt;span style="color: green;"&gt;// Constants from the Platform SDK.&lt;/span&gt;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;EM_SETEVENTMASK&lt;/span&gt; = 1073;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;EM_GETPARAFORMAT&lt;/span&gt; = 1085;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;EM_SETPARAFORMAT&lt;/span&gt; = 1095;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;EM_SETTYPOGRAPHYOPTIONS&lt;/span&gt; = 1226;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;WM_SETREDRAW&lt;/span&gt; = 11;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;TO_ADVANCEDTYPOGRAPHY&lt;/span&gt; = 1;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;PFM_ALIGNMENT&lt;/span&gt; = 8;
    &lt;span style="color: blue;"&gt;private const&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;SCF_SELECTION&lt;/span&gt; = 1;
    
    &lt;span style="color: green;"&gt;// It makes no difference if we use PARAFORMAT or&lt;/span&gt;
    &lt;span style="color: green;"&gt;// PARAFORMAT2 here, so I have opted for PARAFORMAT2.&lt;/span&gt;
    [StructLayout( LayoutKind.Sequential )]
    &lt;span style="color: blue;"&gt;private struct&lt;/span&gt; &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt;
    {
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;cbSize&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;uint&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dwMask&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wNumbering&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wReserved&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dxStartIndent&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dxRightIndent&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dxOffset&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wAlignment&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;cTabCount&lt;/span&gt;;
        [MarshalAs( UnmanagedType.ByValArray, SizeConst = 32 )]
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt;[] &lt;span style="color: #6c6c6c;"&gt;rgxTabs&lt;/span&gt;;
        
        &lt;span style="color: green;"&gt;// PARAFORMAT2 from here onwards.&lt;/span&gt;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dySpaceBefore&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dySpaceAfter&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;dyLineSpacing&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;sStyle&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bLineSpacingRule&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;byte&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;bOutlineLevel&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wShadingWeight&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wShadingStyle&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wNumberingStart&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wNumberingStyle&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wNumberingTab&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wBorderSpace&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wBorderWidth&lt;/span&gt;;
        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: firebrick;"&gt;short&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wBorders&lt;/span&gt;;
    }
    
    [DllImport( "user32", CharSet = CharSet.Auto )]
    &lt;span style="color: blue;"&gt;private static extern&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;hWnd&lt;/span&gt;,
                                           &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;msg&lt;/span&gt;,
                                           &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wParam&lt;/span&gt;,
                                           &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;lParam&lt;/span&gt; );
    
    [DllImport( "user32", CharSet = CharSet.Auto )]
    &lt;span style="color: blue;"&gt;private static extern&lt;/span&gt; &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: red;"&gt;SendMessage&lt;/span&gt;( &lt;span style="color: firebrick;"&gt;HandleRef&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;hWnd&lt;/span&gt;,
                                           &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;msg&lt;/span&gt;,
                                           &lt;span style="color: firebrick;"&gt;int&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;wParam&lt;/span&gt;,
                                           &lt;span style="color: blue;"&gt;ref&lt;/span&gt; &lt;span style="color: firebrick;"&gt;PARAFORMAT&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;lp&lt;/span&gt; );
}

&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span style="color: green;"&gt;/// Specifies how text in a&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;see cref="AdvRichTextBox"/&amp;gt;&lt;/span&gt; &lt;span style="color: green;"&gt;is&lt;/span&gt;
&lt;span style="color: green;"&gt;/// horizontally aligned.&lt;/span&gt;
&lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span style="color: blue;"&gt;public enum&lt;/span&gt; &lt;span style="color: firebrick;"&gt;TextAlign&lt;/span&gt;
{
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// The text is aligned to the left.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Left&lt;/span&gt; = 1,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// The text is aligned to the right.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Right&lt;/span&gt; = 2,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// The text is aligned in the center.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Center&lt;/span&gt; = 3,
    
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: green;"&gt;/// The text is justified.&lt;/span&gt;
    &lt;span style="color: green;"&gt;///&lt;/span&gt; &lt;span style="color: #6c6c6c;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span style="color: #6c6c6c;"&gt;Justify&lt;/span&gt; = 4
}
&lt;/pre&gt;&lt;/code&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;!-- CODE ENDS HERE --&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'll add to this code in future posts and if anyone has any comments or suggestions (or even requests), feel free to ask them. Hope you found this useful.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=182"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=182" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/182.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2003/10/14/182.aspx</guid>
            <pubDate>Tue, 14 Oct 2003 22:02:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/182.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2003/10/14/182.aspx#feedback</comments>
            <slash:comments>64</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/182.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/182.aspx</trackback:ping>
        </item>
        <item>
            <title>I'm Back!</title>
            <category>General</category>
            <link>http://geekswithblogs.net/pvidler/archive/2004/08/22/10046.aspx</link>
            <description>&lt;p&gt;Nearly a year since my last post, I'm finally back (must have lost my password for a while, heheh).&lt;/p&gt;

&lt;p&gt;Anyway, for the last year I've been applying for jobs like crazy. The news is that I won't be unemployed for much longer! In september I'm starting a Ph.D at &lt;a href="http://www.le.ac.uk/"&gt;Leicester University&lt;/a&gt; in the UK. I will be based in the &lt;a href="http://www.le.ac.uk/eg/embedded/"&gt;Embedded Systems Laboratory&lt;/a&gt; and my project is to write a compiler for a not-yet-developed language targetting a not-yet-designed processor -- should be fun! So I'll be a student again, but this time they'll pay me for it (a &lt;em&gt;professional&lt;/em&gt; student)! And I'm using &lt;em&gt;way&lt;/em&gt; too many exclamation marks!&lt;/p&gt;

&lt;p&gt;I've noticed that a lot of people have been commenting on my previous blog entries (particularly the ones on &lt;a href="http://geekswithblogs.net/pvidler/archive/2003/10/14/182.aspx"&gt;Extending RichTextBox&lt;/a&gt;). It's nice to see that people are finding these useful, but I can't really help anyone with the code that is there (I barely remember writing it). Sorry, but it shouldn't be too hard to work out if you play with it.&lt;/p&gt;

&lt;p&gt;I've also changed my email address -- it's now &lt;a href="mailto:pvidler@mailblocks.com"&gt;pvidler@mailblocks.com&lt;/a&gt; and uses a challenge/response spam filter (so be prepared for an automated response if you send me email).&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=10046"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=10046" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/10046.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2004/08/22/10046.aspx</guid>
            <pubDate>Sun, 22 Aug 2004 18:51:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/10046.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2004/08/22/10046.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/10046.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/10046.aspx</trackback:ping>
        </item>
    </channel>
</rss>