<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog &#124; BenHollis.net &#187; .NET</title>
	<atom:link href="http://benhollis.net/blog/tags/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://benhollis.net/blog</link>
	<description>News about BenHollis.net and articles about Ben&#039;s interests</description>
	<lastBuildDate>Fri, 04 Jun 2010 05:39:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Visual Studio debugger is too sensitive about exceptions</title>
		<link>http://benhollis.net/blog/2009/01/13/visual-studio-debugger-is-too-sensitive-about-exceptions/</link>
		<comments>http://benhollis.net/blog/2009/01/13/visual-studio-debugger-is-too-sensitive-about-exceptions/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 07:23:10 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/?p=276</guid>
		<description><![CDATA[I was working on XBList the other day when I hit a peculiarity of Visual Studio. I wanted to call a method asynchronously, so I was using BeginInvoke with a callback, as described in this article on MSDN. So I used BeginInvoke to fire off a method, and the method I invoked happened to throw [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on <a href="http://brh.numbera.com/software/xblist/">XBList</a> the other day when I hit a peculiarity of Visual Studio. I wanted to call a method asynchronously, so I was using BeginInvoke with a callback, as described in <a href="http://msdn.microsoft.com/en-us/library/2e08f6yc(VS.80).aspx">this article on MSDN</a>. So I used BeginInvoke to fire off a method, and the method I invoked happened to throw an exception. I didn&#8217;t expect this to be a big deal &#8211; when the callback was called, I would call EndInvoke which would re-throw the exception and I could deal with it. However, while running in Visual Studio&#8217;s debugger, I got a break and an error dialog that claimed I had an unhandled exception. My code never made it to EndInvoke. It said something like &#8220;Exception <blah> unhandled by user code&#8221;.</p>
<p>It turns out that this is just some weirdness in Visual Studio. If you go to the Debug menu, choose &#8220;Exceptions&#8230;&#8221;, and uncheck &#8220;User-unhandled&#8221; for Common Language Runtime Exceptions, the exception will get properly thrown when EndInvoke is called, and everything&#8217;s fine.</p>
<p class="blogimage"><img src="http://brh.numbera.com/blog/wp-content/uploads/2009/01/exceptions-setting.jpg" alt="exceptions-setting" title="exceptions-setting" width="600" height="125" class="alignnone size-full wp-image-280" /></p>
<p>It&#8217;s annoying that I have to give up the relatively useful unhandled-exception trapping that the Visual Studio debugger gives me, but I guess there&#8217;s no other way around it.</p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2009/01/13/visual-studio-debugger-is-too-sensitive-about-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebLinkLabel Windows Forms Control</title>
		<link>http://benhollis.net/blog/2007/09/09/weblinklabel-windows-forms-control/</link>
		<comments>http://benhollis.net/blog/2007/09/09/weblinklabel-windows-forms-control/#comments</comments>
		<pubDate>Sun, 09 Sep 2007 23:43:38 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2007/09/09/weblinklabel-windows-forms-control/</guid>
		<description><![CDATA[While I was updating my PopupNotify control today, I realized that I had created another useful little control for XBList that I hadn&#8217;t released, the WebLinkLabel Control. This simple control wraps the standard LinkLabel control to make it easier to embed multiple hyperlinks in a label, each of which will load up a URL in [...]]]></description>
			<content:encoded><![CDATA[<p>While I was <a href="http://brh.numbera.com/blog/index.php/2007/09/09/new-version-of-the-popupnotify-windows-forms-control/">updating my PopupNotify control</a> today, I realized that I had created another useful little control for <a href="http://brh.numbera.com/software/xblist/">XBList</a> that I hadn&#8217;t released, the <a href="http://brh.numbera.com/components/winforms/weblinklabel/">WebLinkLabel Control</a>. This simple control wraps the standard <a href="http://msdn2.microsoft.com/en-us/library/897fcdkf.aspx">LinkLabel</a> control to make it easier to embed multiple hyperlinks in a label, each of which will load up a URL in the user&#8217;s default browser when clicked. It&#8217;s not the most complex thing in the world, but it has proven useful for inserting help links into XBList&#8217;s error dialogs, so I suspect it might be of some utility to others. Using it is about as simple as using a standard Label. Just drag the WebLinkLabel onto your form, customize it however you like, then assign a specially-formatted string to the <tt>Text</tt> property. You use &#8220;url&#8221; tags to specify where you want links, like this: &#8220;Hello, this is text &lt;url=http://brh.numbera.com&gt;with a link in it&lt;/url&gt;.&#8221; You can of course have as many links, pointing to as many different URLs, as you would like. If you want to get that formatted string back out, use the <tt>LinkText</tt> property, or if you want to get a flattened view out (&#8220;Hello, this is text with a link in it.&#8221;), use the <tt>Text</tt> property.</p>
<p>This code is licensed under the LGPL, like the <a href="http://brh.numbera.com/components/winforms/">other XBList bits</a> I&#8217;ve released. As usual, I would appreciate it if whoever uses this code would email me to let me know how they&#8217;re using it, just for my own amusement. <a href="http://brh.numbera.com/components/winforms/weblinklabel/">You can download the control right here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2007/09/09/weblinklabel-windows-forms-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Version of the PopupNotify Windows Forms Control</title>
		<link>http://benhollis.net/blog/2007/09/09/new-version-of-the-popupnotify-windows-forms-control/</link>
		<comments>http://benhollis.net/blog/2007/09/09/new-version-of-the-popupnotify-windows-forms-control/#comments</comments>
		<pubDate>Sun, 09 Sep 2007 22:20:49 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[PopupNotify]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2007/09/09/new-version-of-the-popupnotify-windows-forms-control/</guid>
		<description><![CDATA[A couple years back I posted the source of XBList&#8216;s tray notification control on my site as the PopupNotify control. I licensed it under the LGPL so people could use it for their own applications. While I requested that whoever used it should let me know, I&#8217;ve never received any email about it until this [...]]]></description>
			<content:encoded><![CDATA[<p>A couple years back I posted the source of <a href="http://brh.numbera.com/software/xblist/">XBList</a>&#8216;s tray notification control on my site as the <a href="http://brh.numbera.com/components/winforms/popupnotify/">PopupNotify</a> control. I licensed it under the LGPL so people could use it for their own applications. While I requested that whoever used it should let me know, I&#8217;ve never received any email about it until this week, when somebody wrote to tell me that they had been using it but it didn&#8217;t work on Vista, and they wanted some help getting it to work. Despite the fact that I would rather they had told me about this beforehand, I&#8217;ve taken this as an opportunity to update the component. I just pulled out the current version of the control that I&#8217;m using for XBList, which has a much prettier Vista-style look, less P/Invoke calls, and other .NET 2.0 improvements. I&#8217;ve left the 1.1 version of the control around for anyone who wants to use it but hasn&#8217;t updated to .NET 2.0 yet.</p>
<p class="blogimage"><a href="http://brh.numbera.com/components/winforms/popupnotify/"><img src='http://brh.numbera.com/blog/wp-content/uploads/2007/09/justthepopup.jpg' alt='The new, Vista-style popup' /></a></p>
<p>Hopefully this component will continue to be useful to other developers, and they&#8217;ll let me know if they&#8217;re using it in their projects, since it&#8217;s just so much more fun to release stuff for free when you get to see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2007/09/09/new-version-of-the-popupnotify-windows-forms-control/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>JavaOne 2007</title>
		<link>http://benhollis.net/blog/2007/05/24/javaone-2007/</link>
		<comments>http://benhollis.net/blog/2007/05/24/javaone-2007/#comments</comments>
		<pubDate>Thu, 24 May 2007 09:26:17 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[javaone]]></category>
		<category><![CDATA[javaone2007]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2007/05/24/javaone-2007/</guid>
		<description><![CDATA[I had the opportunity to go to the JavaOne conference two weeks ago, in San Francisco. It was quite an experience for me as I had never been to a technical conference before, let alone one of that size. I&#8217;m not exactly a Java enthusiast, but I am a Java developer. I spend most of [...]]]></description>
			<content:encoded><![CDATA[<p>I had the opportunity to go to the JavaOne conference two weeks ago, in San Francisco. It was quite an experience for me as I had never been to a technical conference before, let alone one of that size. I&#8217;m not exactly a Java enthusiast, but I am a Java developer. I spend most of my day writing Java code, so going to all the presentations about making <em>better</em> Java code, as well as interacting with Java developers from all over the world, was really educational.</p>
<p class="blogimage"><a href="http://flickr.com/photos/dalangalma/sets/72157600257721836/"><img src="http://farm1.static.flickr.com/213/511875596_b43f8f52ee_m.jpg"/></a></p>
<p>I noticed a few things from the conference that I wanted to write down before I forgot. The first is that even in Java-land, scripting languages are hot. Lots of people were talking about <a href="http://jruby.codehaus.org/">JRuby</a>, Groovy, JavaScript, JavaFX Script, and more. JRuby in particular was getting a lot of excitement from everyone who&#8217;s been hearing for the last couple years about how cool Ruby on Rails is. I&#8217;ve seen a lot of Rails demonstrations and they&#8217;ve failed to impress me but the Ruby language itself is very appealing, especially to someone like myself who mainly scripts in Perl or JavaScript. I&#8217;ve definitely been convinced to use Ruby for my next personal web app project, and the combination JRuby&#8217;s speed and native access to Java code will make me feel a lot better about it.</p>
<p>There were a lot of talks about static analysis tools, and <a href="http://findbugs.sourceforge.net/">FindBugs</a> in particular. I&#8217;ve been using FindBugs on my Java code (and <a href="http://www.gotdotnet.com/Team/FxCop/">FxCop </a>for my .NET code) for quite a while, but a few of the presentations gave me a much better idea of how powerful static code analysis can be. One of the best ideas is using <a href="http://findbugs.sourceforge.net/manual/annotations.html">special annotations</a> that more clearly document the intended behavior of your code. Not only does this serve as additional documentation, it helps you design your classes better <em>and</em> helps out your code analysis tools. One of the first things I did when I got back was grab the latest FindBugs release and start sprinkling those magic annotations all over my code, and from now on I&#8217;ll be writing them in whenever I write new code.</p>
<p>I also got more in-depth exposure to the <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> philosophy, which I had heard a lot about but not really thought about too much. I really like the idea, but until the tools get to the point where I can write up some sort of service description and generate client code like I can do with <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language">WSDL</a>, I&#8217;m going to hang back a bit. Maybe <a href="http://weblogs.java.net/blog/mhadley/archive/2005/05/introducing_wad.html">WADL</a> will catch on. I also got a better explanation of <a href="http://openid.net/">OpenID</a> than I had gotten previously, and I&#8217;m really impressed. I like that it&#8217;s so simple, and that it can still integrate with technologies like CardSpace in a way that adds value to both sides. I searched for an open implementation of an OpenID provider that uses CardSpace, but it doesn&#8217;t look like any exist yet. </p>
<p>Another, less explicit theme at the conference was that the Java community has noticed the great design of C# and the .NET framework and are trying to fit some of that back into Java. I&#8217;ve always felt that C# was &#8220;Java done right&#8221;, and the number of JSRs (Java Specification Requests) that I saw for C#/.NET features is a testament to that. JavaSE 5 already added annotations (attributes), generics, foreach, enums, variable length arguments lists, and <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html">autoboxing</a>, all features from C# 1.0 or 2.0. The stuff that&#8217;s being discussed for JavaSE 7 and beyond includes &#8220;<a href="http://jcp.org/en/jsr/detail?id=294">superpackages</a>&#8221; that look a lot like assemblies, <a href="http://en.wikipedia.org/wiki/Continuation">continuations</a>, a &#8220;<a href="http://www.25hoursaday.com/CsharpVsJava.html#idisposable">using</a>&#8221; statement, generics that don&#8217;t use <a href="http://java.sun.com/docs/books/tutorial/java/generics/erasure.html">type erasure</a>, <a href="http://www.codeproject.com/useritems/Indexer_in_C__Programmin.asp">indexers</a>, and switching on strings. I think this is great &#8211; C# made a lot of great improvements that were no doubt based at least in part on experience with Java, so it&#8217;s natural for Java to get back some of that. I didn&#8217;t see much talk of any of the C# 3.0 features like <a href="http://msdn.microsoft.com/data/ref/linq/">LINQ</a>, object and list initializers, extension methods, etc. I did see some talk about incorporating <a href="http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx">lambda expressions</a>, though, which would be pretty nice.</p>
<p>Despite the fact that the Java language has some catching up to do, one glaring advantage of Java over .NET became apparent to me while I was there. I&#8217;m not talking about the platform-independence advantage, though that is certainly there &#8211; I don&#8217;t think I could imagine building a large, scalable distributed service with Windows machines. No, what I&#8217;m talking about is the community. That&#8217;s not to put down the large and active .NET community, it&#8217;s just that the Java community is <em>huge</em>. And especially through open source, there&#8217;s just a lot more going on. I feel like a large part of this is that Sun and other Java leaders have been willing to incorporate the community&#8217;s best products into the standard toolset. Products like <a href="http://ant.apache.org/">ant</a>, <a href="http://www.eclipse.org/">Eclipse</a>, <a href="http://www.springframework.org/">Spring</a>, <a href="http://www.junit.org/">JUnit</a>, and even JRuby are accepted tools. Meanwhile on the .NET side, you&#8217;re basically taking whatever Microsoft gives you. And while that can usually be good, Microsoft runs the risk of ignoring the direction people are actually heading in.</p>
<p>In the end, I left the conference with much the same opinion of Java that I had in the beginning. Java is a tool, and a good tool, but not a particularly exciting tool. It does have some exciting features (I love <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX</a>), and after my week in the Moscone Center, I feel like I can be more competent at creating Java-based software. Maybe I just haven&#8217;t worked on the right Java projects. I hope as my experience with the platform grows, I&#8217;ll be able to contribute more, either through this blog or through open-source projects. And who knows, maybe one day I&#8217;ll really feel like a Java Guy.</p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2007/05/24/javaone-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting the correct default font in .NET Windows Forms apps</title>
		<link>http://benhollis.net/blog/2007/04/11/setting-the-correct-default-font-in-net-windows-forms-apps/</link>
		<comments>http://benhollis.net/blog/2007/04/11/setting-the-correct-default-font-in-net-windows-forms-apps/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 09:05:17 +0000</pubDate>
		<dc:creator>Ben Hollis</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://brh.numbera.com/blog/index.php/2007/04/11/setting-the-correct-default-font-in-net-windows-forms-apps/</guid>
		<description><![CDATA[I was working on XBList the other night when I realized something - the font used in its dialogs and the friends list wasn't Segoe UI. Segoe UI is the very pretty, ClearType-optimized new default dialog font in Windows Vista. In Windows XP and 2000, it's Tahoma, and in earlier editions it was Microsoft Sans [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on <a href="http://brh.numbera.com/software/xblist/">XBList</a> the other night when I realized something - the font used in its dialogs and the friends list wasn't <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/uxguide/uxguide/Resources/WhatsNewInVista/fonts.asp">Segoe UI</a>. Segoe UI is the very pretty, ClearType-optimized new default dialog font in Windows Vista. In Windows XP and 2000, it's Tahoma, and in earlier editions it was Microsoft Sans Serif. You can see the subtle differences between them:</p>
<p class="blogimage"><img src='http://brh.numbera.com/blog/wp-content/uploads/2007/04/ms_system_fonts.png' alt='Microsoft System Fonts' /></p>
<p>In .NET and Windows Forms, the default font for controls is actually Microsoft Sans Serif, not the operating system's default dialog font! <a href="http://weblogs.asp.net/kdente/archive/2005/03/13/394499.aspx">Kevin Dente explains this on his blog.</a> This is not the only time Microsoft's dropped the ball on this - if you go through some dialogs in Vista you'll see that many of them use Tahoma or even Microsoft Sans Serif instead of Segoe UI. This is pretty funny, especially when Rule #1 of the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/uxguide/uxguide/Resources/TopRules/TopRules.asp">Top Rules for the Windows Vista User Experience</a> is "Use the Aero Theme and System Font (Segoe UI)". <a href="http://blogs.msdn.com/michkap/archive/2006/06/11/626100.aspx">Mitch Kaplan offers up a pretty good explanation</a> for why getting it all right is very hard, but having a mix of old and new fonts still looks shoddy. </p>
<p>I don't want my apps to look shoddy. Embarrassingly enough, I've been hardcoding Tahoma in all my apps to get the more "modern" XP look.  Now that Vista's on the scene, it's clear that I want to select the correct default font for whichever OS my app is running on. As Kevin points out, <code>Control.DefaultFont</code> is no help here - it's what's driving Windows Forms' default choice of Microsoft Sans Serif in the first place. After some digging I found <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115408">this Visual Studio feedback ticket (sign in required)</a>, where the Visual Studio guys explain that, while they couldn't fix the default, they did create a SystemFonts class to help out. They recommend putting this code in your Form's constructor:</p>
<div class="igBar"><span id="lcsharp-3"><a href="#" onclick="javascript:showPlainTxt('csharp-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-3">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Font</span> = SystemFonts.<span style="color: #0000FF;">DialogFont</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">InitializeComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Unfortunately, this doesn't work in a number of ways. The first is that on Vista, <code>SystemFonts.DialogFont</code> is... Tahoma! Closer, but not quite right yet. If you pop open SystemFonts in <a href="http://www.aisto.com/roeder/dotnet/">Reflector</a>, you'll see that the DialogFont property just does some simple platform-detection, and then just hardcodes Tahoma. This worked when it was just 2000/XP vs. 9x, but Vista throws it for a total loop. Fortunately the fix is easy - use <code>SystemFonts.MessageBoxFont</code> instead. This one seems to always return the correct default dialog font. </p>
<p>However, I ran into one more problem. If I set the default font on the Form, like the code above does, I get weird, bloated controls:</p>
<p class="blogimage"><img src='http://brh.numbera.com/blog/wp-content/uploads/2007/04/segoe_bad.png' alt='Setting the default font on the form screws up controls' /></p>
<p>Fortunately I've got a solution for that one too. Instead of setting the font on the Form and letting it inherit, just loop through the <code>Controls</code> property, and individually set the right font on each control:</p>
<div class="igBar"><span id="lcsharp-4"><a href="#" onclick="javascript:showPlainTxt('csharp-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-4">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">// Set the default dialog font on each child control</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>Control c <span style="color: #0600FF;">in</span> Controls<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; c.<span style="color: #0000FF;">Font</span> = SystemFonts.<span style="color: #0000FF;">MessageBoxFont</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">// Use a larger, bold version of the default dialog font for one control</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">label1</span>.<span style="color: #0000FF;">Font</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Font<span style="color: #000000;">&#40;</span>SystemFonts.<span style="color: #0000FF;">MessageBoxFont</span>.<span style="color: #0000FF;">Name</span>, 12f, FontStyle.<span style="color: #0000FF;">Bold</span>, GraphicsUnit.<span style="color: #0000FF;">Point</span><span style="color: #000000;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now I get a more familiar-looking dialog:</p>
<p class="blogimage"><img src='http://brh.numbera.com/blog/wp-content/uploads/2007/04/segoe_good.png' alt='Setting the default font on each control looks fine' /></p>
<p>I could always make a subclass of Form to do this for me, but I'm OK with copying it into each new form. With this code, all my controls come up with the pretty new Segoe UI font in Windows Vista, and Tahoma in XP. </p>
]]></content:encoded>
			<wfw:commentRss>http://benhollis.net/blog/2007/04/11/setting-the-correct-default-font-in-net-windows-forms-apps/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
