<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/"><channel><title>Duncan Mackenzie .Net</title><description> Oxite  blogArchives</description><link>http://duncanmackenzie.net</link><language>en-us</language><pubDate>Wed, 20 Aug 2008 03:19:53 GMT</pubDate><generator>Oxite</generator><item><title>January 2005 "Advanced Basics" column up on MSDN</title><description>&lt;p&gt;Yet another control development topic... this time I'm building a 'star rating' control, similar to what you find in Windows Media Player's UI... &lt;/p&gt;
&lt;p&gt;&lt;img src="http://msdn.microsoft.com/msdnmag/issues/05/01/AdvancedBasics/fig01.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Check out the article here: &lt;a href="http://msdn.microsoft.com/msdnmag/issues/05/01/AdvancedBasics/default.aspx"&gt;Creating a Five-Star Rating Control &lt;/a&gt;&lt;/p&gt;</description><comments>http://duncanmackenzie.net/blog/January-2005-Advanced-Basics-column-up-on-MSDN/default.aspx</comments><link>http://duncanmackenzie.net/blog/January-2005-Advanced-Basics-column-up-on-MSDN/default.aspx</link><pubDate>Tue, 14 Dec 2004 14:29:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/January-2005-Advanced-Basics-column-up-on-MSDN/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>9</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/518/trackback/default.aspx</trackback:ping><category>Visual Basic</category></item><item><title>Enter Instead of Tab</title><description>&lt;p&gt;I received another interesting, and common, question today about using Enter instead of (or in addition to) the Tab key to move the focus between fields on a form. Well, that isn't too hard to accomplish, but it can get tricky once you consider all the different situations...&lt;/p&gt;

&lt;p&gt;First, the easy... set your Form's &lt;b&gt;KeyPreview&lt;/b&gt; property to true, override &lt;b&gt;OnKeyUp&lt;/b&gt; (or OnKeyDown... can't think of any real reason to use one or the other in this case), check for the Enter key, then call your Form's &lt;b&gt;ProcessTabKey&lt;/b&gt; method.&lt;/p&gt;

&lt;pre&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Protected&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Overrides&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt; OnKeyUp(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; e &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.Windows.Forms.KeyEventArgs)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; e.KeyCode = Keys.Enter &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;
            e.Handled = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;True&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.ProcessTabKey(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Not&lt;/font&gt; e.Shift)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Else&lt;/font&gt;
            e.Handled = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;False&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;MyBase&lt;/font&gt;.OnKeyUp(e)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt;

&lt;/pre&gt;

&lt;p&gt;Now... what is wrong with that code?&lt;/p&gt;
&lt;p&gt;In the simple case, nothing... but I found a couple of issues with it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you have the &lt;b&gt;AcceptButton&lt;/b&gt; property of your Form set, which means you have a default button on the Form, then your code will never get called... the key event is handled at some point farther up the chain&lt;/li&gt;
&lt;li&gt;If you have multiline textboxes on your Form, the enter key will not work within them ... which means your users will not be able to create any new lines in those textboxes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first issue is easiest to solve if you just decide not to have a default button set on your form, because any other solution (such as overriding &lt;b&gt;ProcessDialogKey&lt;/b&gt;) will stop the default button behaviour so that the enter key can be used for moving focus.&lt;/p&gt;
&lt;p&gt;The second problem is not too difficult to handle, you can modify your code to check for certain properties of the TextBox control, but this may not work for other controls that also wish to accept the Enter key as input.&lt;/p&gt;

&lt;pre&gt;
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; e.KeyCode = Keys.Enter &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;TypeOf&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.ActiveControl &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Is&lt;/font&gt; TextBox &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;
                &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; tb &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; TextBox = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;DirectCast&lt;/font&gt;(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.ActiveControl, TextBox)
                &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; tb.Multiline &lt;font color="Blue" family="Microsoft Sans Serif"&gt;AndAlso&lt;/font&gt; tb.AcceptsReturn &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;
                    e.Handled = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;False&lt;/font&gt;
                    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;MyBase&lt;/font&gt;.OnKeyUp(e)
                    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Exit&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt;
                &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;
            e.Handled = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;True&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.ProcessTabKey(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Not&lt;/font&gt; e.Shift)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Else&lt;/font&gt;
            e.Handled = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;False&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;MyBase&lt;/font&gt;.OnKeyUp(e)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;

&lt;/pre&gt;

&lt;p&gt;Oh, and there was another part to the original question... what if I want to respond to the Enter key to do some processing on the value that was just entered. Well, for that result either with or without the 'enter instead of tab' code, you would just choose to handle the &lt;b&gt;KeyDown&lt;/b&gt; event for the control in question.&lt;/p&gt;

&lt;pre&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Private&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt; TextBox2_KeyDown(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; sender &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Object&lt;/font&gt;, _
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; e &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.Windows.Forms.KeyEventArgs) _
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Handles&lt;/font&gt; TextBox2.KeyDown
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; e.KeyCode = Keys.Enter &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;MsgBox&lt;/font&gt;(&lt;font color="Red" family="Microsoft Sans Serif"&gt;"do something!"&lt;/font&gt;)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;
    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt;
&lt;/pre&gt;

&lt;p&gt;Of course, after your code 'does something', the focus will also move to the next control... both sets of code, the Form's &lt;b&gt;OnKeyUp&lt;/b&gt; routine and the control's &lt;b&gt;KeyDown&lt;/b&gt; event handler, execute when the user hits Enter on this particular control.&lt;/p&gt;
&lt;p&gt;I've gotten flack in the past for articles that discuss &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncodefun/html/code4fun07012004.asp" target="_blank"&gt;'simple' topics&lt;/a&gt;, but I hope this is useful to some of the folks that find it :)&lt;/p&gt;</description><comments>http://duncanmackenzie.net/blog/Enter-Instead-of-Tab/default.aspx</comments><link>http://duncanmackenzie.net/blog/Enter-Instead-of-Tab/default.aspx</link><pubDate>Mon, 13 Dec 2004 17:07:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/Enter-Instead-of-Tab/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>17</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/517/trackback/default.aspx</trackback:ping><category>Visual Basic</category></item><item><title>Lead Developer position available with MSDN</title><description>&lt;p&gt;Just posted recently, there is a opening at MSDN for a "Software Development Engineering Lead". This is within the same group that I have just joined and it looks like a great job for the right person. Here is a brief snippet from the &lt;a href="http://www.microsoft.com/careers/search/details.aspx?JobID=2e310b8d-a7ca-4105-b7bd-fcaf8eee5054" target="_blank"&gt;full job description&lt;/a&gt;....&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Come leverage state-of-the-art technology! The MSDN/TechNet development team is looking for you to help us innovate in many exciting areas for our Development and IT Professional communities.&lt;/p&gt;

&lt;p&gt;We are looking for seasoned Development Lead that can deliver and strategize our tooling for Content Management, Personalization, Rendering and Publishing efforts. This is highly collaborative position and you will be working closely with the teams that we depend on (for example the Assistance Platform and the Microsoft.com Platform teams) to integrate and couple our tools to a variety of backend systems and aggregating data sources.&lt;/p&gt;

&lt;p&gt;We have a broad charter for content publishing, tooling and workflow applications for our core audiences and the broader areas of Microsoft.com and for all of our worldwide subsidiaries. We will highly value your expertise in areas of locale specific publishing, site personalization and content targeting. We want to improve the relevance of our content and site experiences for our customers by providing personalized and targeted content. Familiarity and experience with RSS, meta-data and taxonomies in relationship to application development will be important to this role.&lt;/p&gt;

&lt;/blockquote&gt;

&lt;p&gt;For the full details and/or to submit a resume, follow &lt;a href="http://www.microsoft.com/careers/search/details.aspx?JobID=2e310b8d-a7ca-4105-b7bd-fcaf8eee5054" target="_blank"&gt;this link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Based on the response to past job postings, I'd like to be clear about one thing... &lt;b&gt;do not submit your resume to me, do not post it in the comments to this blog entry&lt;/b&gt; ... either approach will basically be ignored (unless you are someone who knows me well enough that you are looking for a reference).&lt;/p&gt;</description><comments>http://duncanmackenzie.net/blog/Lead-Developer-position-available-with-MSDN/default.aspx</comments><link>http://duncanmackenzie.net/blog/Lead-Developer-position-available-with-MSDN/default.aspx</link><pubDate>Mon, 13 Dec 2004 15:29:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/Lead-Developer-position-available-with-MSDN/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>1</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/516/trackback/default.aspx</trackback:ping><category>MSDN Development</category><category>Visual Basic</category><category>Visual C#</category></item><item><title>Follow up to 'drawing rotated text'</title><description>&lt;p&gt;The same programmer who ask for &lt;a href="http://blogs.duncanmackenzie.net/duncanma/archive/2004/12/02/913.aspx" target="_blank"&gt;an example of rotated text&lt;/a&gt; is back with another interesting request; how to partially fill a circle from the bottom up... &lt;/p&gt;
&lt;p&gt;&lt;img src="http://msdn.microsoft.com/vbasic/art/compass_filled.png" /&gt;&lt;/p&gt;

&lt;p&gt;as if it was a glass that you've poured water into... so here goes (this is only a snippet of the code, see &lt;a href="http://blogs.duncanmackenzie.net/duncanma/archive/2004/12/02/913.aspx" target="_blank"&gt;the original post &lt;/a&gt;for the rest);&lt;/p&gt;

&lt;pre&gt;

    &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Protected&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Overrides&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt; OnPaint( _
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; e &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.Windows.Forms.PaintEventArgs)
        e.Graphics.&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Clear&lt;/font&gt;(&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.BackColor)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; bounds &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Rectangle
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; g &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Graphics
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; rotation &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Single&lt;/font&gt; = 0
        g = e.Graphics
        bounds = &lt;font color="Blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; Rectangle(50, 50, _
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Width - 100, &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Height - 100)
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; percentageToFill &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Single&lt;/font&gt; = 0.75
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; fillArea &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="Blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; Rectangle( _
            50, 50 + ((&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Height - 100) * (1 - percentageToFill)), _
            &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Width - 100, ((&lt;font color="Blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Height - 100) * percentageToFill))
        &lt;font color="Blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; oldClip &lt;font color="Blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Region = g.Clip
        g.SetClip(fillArea)
        g.FillEllipse(Brushes.Red, bounds)
        g.Clip = oldClip
        g.DrawEllipse(Pens.Black, bounds)


&lt;/pre&gt;

&lt;p&gt;There is probably more than one way to do this, but my code just fills the whole circle, but sets the clip region first so that it only draws within the bounds of a certain rectangle...&lt;/p&gt;</description><comments>http://duncanmackenzie.net/blog/Follow-up-to-drawing-rotated-text/default.aspx</comments><link>http://duncanmackenzie.net/blog/Follow-up-to-drawing-rotated-text/default.aspx</link><pubDate>Thu, 09 Dec 2004 16:05:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/Follow-up-to-drawing-rotated-text/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>6</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/515/trackback/default.aspx</trackback:ping><category>Visual Basic</category></item><item><title>DataGrid programming...</title><description>&lt;p&gt;Customizing the data grid (in Windows Forms) was always one of the most popular topics on the C# or VB developer centers, so I'm sure a lot of people will be interested in this article. It is in C#, so far, but if you'd like to see it in VB I'd suggest you email the writer (email at the bottom of the article).&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/smartclient/default.aspx?pull=/library/en-us/dnwinforms/html/datagridcolumnstyle1.asp" target="_blank"&gt;Styling with the DataGridColumnStyle, Part 1&lt;/a&gt;&lt;br /&gt;
Explains the rendering infrastructure of the Windows Forms DataGrid control, including the various resources that the DataGrid utilizes to display its data.&lt;/p&gt;&lt;/blockquote&gt;</description><comments>http://duncanmackenzie.net/blog/DataGrid-programming/default.aspx</comments><link>http://duncanmackenzie.net/blog/DataGrid-programming/default.aspx</link><pubDate>Thu, 09 Dec 2004 15:04:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/DataGrid-programming/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>153</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/514/trackback/default.aspx</trackback:ping><category>Visual Basic</category><category>Visual C#</category></item><item><title>I just can't get enough Penny Arcade...</title><description>&lt;p&gt;He was talking about the generic bad guys in the new Prince of Persia game, but this line crosses into Halo, and it is so true...&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;"Halo has those little grunts, and I guess I'm supposed to feel like a bad-ass when I destroy them but I actually just feel like an asshole. They both seem like races that just fell in with the wrong crowd. What they need are compelling after school activities, not death."&lt;/p&gt;&lt;p&gt;From &lt;a href="http://www.penny-arcade.com/news.php3?date=2004-12-3" target="_blank"&gt;Penny Arcade (December 3rd, 2004)&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;In Halo the grunts have a lot of great lines, the general gist of which is that they are pretty terrified of you... and they run away a lot... so, while you kinda have to get them (even little creatures can hold weapons), it just seems wrong.&lt;/p&gt;</description><comments>http://duncanmackenzie.net/blog/I-just-cant-get-enough-Penny-Arcade/default.aspx</comments><link>http://duncanmackenzie.net/blog/I-just-cant-get-enough-Penny-Arcade/default.aspx</link><pubDate>Sun, 05 Dec 2004 17:14:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/I-just-cant-get-enough-Penny-Arcade/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>0</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/513/trackback/default.aspx</trackback:ping><category>Personal Musings</category><category>XBox</category></item><item><title>Drawing rotated text...</title><description>&lt;p&gt;A customer emailed me today (via the VB FAQ blog) with a question; "how can I output text at different angles, to write the cardinal points around a compass for example..." so I decided to fire up a quick sample&lt;/p&gt;
		&lt;pre&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Public&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Enum&lt;/font&gt; Direction &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Integer&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;N = 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;NW = 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;W = 2&lt;br /&gt;&amp;nbsp;&amp;nbsp;SW = 3&lt;br /&gt;&amp;nbsp;&amp;nbsp;S = 4&lt;br /&gt;&amp;nbsp;&amp;nbsp;SE = 5&lt;br /&gt;&amp;nbsp;&amp;nbsp;E = 6&lt;br /&gt;&amp;nbsp;&amp;nbsp;NE = 7&lt;br /&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Enum&lt;/font&gt;&lt;br /&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Protected&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Overrides&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt; OnPaint(&lt;font color="blue" family="Microsoft Sans Serif"&gt;ByVal&lt;/font&gt; e &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.Windows.Forms.PaintEventArgs)&lt;br /&gt;&amp;nbsp;&amp;nbsp;e.Graphics.&lt;font color="blue" family="Microsoft Sans Serif"&gt;Clear&lt;/font&gt;(&lt;font color="blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.BackColor)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; bounds &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Rectangle&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; g &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Graphics&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; rotation &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Single&lt;/font&gt; = 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;g = e.Graphics&lt;br /&gt;&amp;nbsp;&amp;nbsp;bounds = &lt;font color="blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; Rectangle(50, 50, &lt;font color="blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Width - 100, &lt;font color="blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Height - 100)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; rect &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; System.Drawing.RectangleF&lt;br /&gt;&amp;nbsp;&amp;nbsp;g.DrawEllipse(Pens.Black, bounds)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; myMatrix &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; Drawing2D.Matrix&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; sf &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; StringFormat(StringFormatFlags.NoWrap)&lt;br /&gt;&amp;nbsp;&amp;nbsp;sf.Alignment = StringAlignment.Center&lt;br /&gt;&amp;nbsp;&amp;nbsp;myMatrix = g.Transform()&lt;br /&gt;&amp;nbsp;&amp;nbsp;rect = &lt;font color="blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; System.Drawing.RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;For&lt;/font&gt; i &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Integer&lt;/font&gt; = 0 &lt;font color="blue" family="Microsoft Sans Serif"&gt;To&lt;/font&gt; 7&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt; i &amp;gt; 0 &lt;font color="blue" family="Microsoft Sans Serif"&gt;Then&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myMatrix.RotateAt(45, &lt;font color="blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; PointF(&lt;font color="blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Width / 2, &lt;font color="blue" family="Microsoft Sans Serif"&gt;Me&lt;/font&gt;.Height / 2), Drawing.Drawing2D.MatrixOrder.Append)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g.Transform = myMatrix&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;If&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Dim&lt;/font&gt; directionString &lt;font color="blue" family="Microsoft Sans Serif"&gt;As&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;String&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;directionString = System.&lt;font color="blue" family="Microsoft Sans Serif"&gt;Enum&lt;/font&gt;.GetName(&lt;font color="blue" family="Microsoft Sans Serif"&gt;GetType&lt;/font&gt;(Direction), i)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g.DrawString(directionString, &lt;font color="blue" family="Microsoft Sans Serif"&gt;New&lt;/font&gt; Font(&lt;font color="red" family="Microsoft Sans Serif"&gt;"Arial"&lt;/font&gt;, 12, FontStyle.Bold), Brushes.Black, rect, sf)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="blue" family="Microsoft Sans Serif"&gt;Next&lt;/font&gt;&lt;br /&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;End&lt;/font&gt; &lt;font color="blue" family="Microsoft Sans Serif"&gt;Sub&lt;/font&gt;&lt;br /&gt; &lt;/pre&gt;
		&lt;br /&gt; &lt;p&gt;If you want to try this code, create a new Windows Forms application in VS.NET 2003, and paste this code into your Form, after the "Windows Form Designer generated code" region.&lt;/p&gt; &lt;p&gt;The result will be an image like this: &lt;img src="http://msdn.microsoft.com/vbasic/art/compass.png" /&gt;&lt;/p&gt; &lt;p&gt;If you are looking for more info on GDI+ drawing in VB.NET, I'd suggest &lt;a href="http://msdn.microsoft.com/library/en-us/dndotnet/html/designsurface.asp" target="_blank"&gt;my article on the subject&lt;/a&gt; :) and there is &lt;a href="http://www.amazon.com/exec/obidos/ASIN/0321160770/duncanmackenz-20?dev-t=mason-wrapper%26camp=2025%26link_code=xm2" target="_blank"&gt;a good book available from AW&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Update: &lt;/strong&gt;Ugh... I messed up the directions... and didn't even notice (thanks Edward!!)&lt;/p&gt; &lt;p&gt;The enum should be &lt;/p&gt; &lt;p&gt;······· N = 0 &lt;br /&gt;······· NE = 1&lt;br /&gt;········E = 2&lt;br /&gt;······· SE = 3&lt;br /&gt;······· S = 4&lt;br /&gt;······· SW = 5&lt;br /&gt;········W = 6&lt;br /&gt;······· NW = 7&lt;br /&gt;&lt;/p&gt;</description><comments>http://duncanmackenzie.net/blog/Drawing-rotated-text/default.aspx</comments><link>http://duncanmackenzie.net/blog/Drawing-rotated-text/default.aspx</link><pubDate>Thu, 02 Dec 2004 20:06:00 GMT</pubDate><guid isPermaLink="true">http://duncanmackenzie.net/blog/Drawing-rotated-text/default.aspx</guid><dc:creator>Duncan Mackenzie</dc:creator><slash:comments>9</slash:comments><trackback:ping>http://duncanmackenzie.net/blog/512/trackback/default.aspx</trackback:ping><category>Visual Basic</category></item></channel></rss>