Articles in the How-To category

Transparent WinForms Label

By Eric — 2 minute read

Easy control transparency isn't exactly a hallmark of Windows Forms. If you have a form with a background image or a gradient, the stock controls paint with a solid background to give a criminally egregious aesthetic.

If you search the web for a solution, you might come up with a …

Read more...

Rounded Rectangluar Regions

By Eric — 4 minute read

There are lots of examples that demonstrate how to draw a rectangle with rounded corners using GDI+ in .NET. Converting such a rectangle to a Region so that it can be filled or be used for the geometry of a window can have less than perfect results, though.

For example …

Read more...

Silverlight Localization

By Eric — 6 minute read

The official Silverlight documentation about localization gives lots of information about working with resource files, but it is kind of scant on how to actually get localized strings to show up in the UI in a reasonable way. For example, an unreasonable way would be to set the text/content …

Read more...

Unit Testing Silverlight View Models

By Eric — 3 minute read

Being relatively new to Silverlight development, I've not had the good sense to accept conventional wisdom that the Visual Studio unit test framework can't be used to test Silverlight code. For testing view models at least, I've been successfully using Mstest and Rhino Mocks for a few months now.

One …

Read more...

Guidelines for Method Parameter and Return Types

By Eric — 1 minute read

I've been reading Jeffrey Richter's CLR via C# lately, and just read a section titled "Declaring a Method's Parameter Types". That title doesn't exactly promise a riveting read, but it did a nice job of articulating some guidelines for method parameter and return types, independent of any particular programming language …

Read more...

Converting from Visual Studio 2005 to Visual Studio 2008

By Eric — 3 minute read

I've just finished switching over our development environment from Visual Studio 2005 to Visual Studio 2008 (except for a C++ solution that uses boost, which will take some further effort). These are the things that I needed to do, and the gotchas I encountered.

  1. Getting installed - Aside from being a …

Read more...

Getting the Host's Main Window Handle in an Office Add-in

By Eric — 1 minute read

Sometimes you want the window handle of the host application when you're writing an Office add-in. Excel includes that as a property of the Application object in newer versions of the object model, but Word and PowerPoint don't. I seem to remember some sample code from Microsoft that suggests using …

Read more...

Paste Special Macro for Word

By Eric — 1 minute read

I sometimes wonder how often the default paste operation in an application is appropriate. Maybe I'm abnormal (maybe?) but it seems like 73.2% of the time, I want pasted text to match the formatting of where it is going rather than where it came from. I guess the exception …

Read more...

.NET BackgroundWorker Summary

By Eric — 3 minute read

The System.ComponentModel.BackgroundWorker class makes it easy to code a long running operation with the ability to provide progress, cancellation, and notification of completion. It is particularly nice for UI because while the long running operation executes on a thread pool thread, notifications of progress and completion are marshalled …

Read more...

Temporary CommandBar Customizations in Word

By Eric — 3 minute read

It's common for an Office add-in to put some custom menu items or toolbar buttons in the UI of the hosting application. The method to call to do this is CommandBars.Add. It is also typical that you'd like those customizations to appear so long as the add-in gets loaded …

Read more...