Using BackgroundWorker Effectively

If you are not familiar with the BackgroundWorker, it is a newly released component within Windows Forms 2.0 which adds safe, easy, multithreading capabilities to your application.    By using a pattern of method calls (RunWorkerAsync, ReportProgress) and event callbacks (DoWork, ProgressChanged, RunWorkerCompleted), BackgroundWorker helps you easily create a background thread and factor out the…


Office feedback

I’ve been following Crabby Office Lady, and this week she has links to sending in feedback/product suggestions for office products.  


Notify applications where the form disappears from the taskbar on minimize

Jim asks: “I’ve been following your Windows Forms articles, and was hoping that you could post about the correct way to minimize a Windows Form to the tray. The ShowInTask property of the Form is mentioned in newsgroups, but the Form still shows in the Alt+Tab list.” The best way to handle this situation is…


New samples: TLP ToolStrip, TrackBar for ToolStrip and Readonly Controls

Here’s three new samples I whipped up recently – hope you find them interesting/useful! Creating TrackBar for your ToolStrip (ToolStripControlHost sample)Using ToolStrip.LayoutStyle = Table in the designerHow to make any old control “readonly” without going dark grey


Using TableLayout in ToolStrip in the Designer

The following sample creates an extender provider for toolstrip which adds the properties/methods that make LayoutStyle.Table designable. using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;using System.ComponentModel; namespace Microsoft.Samples {    [ProvideProperty(“ColumnSpan”, typeof(ToolStripItem))]    [ProvideProperty(“RowSpan”, typeof(ToolStripItem))]    [ProvideProperty(“Anchor”, typeof(ToolStripItem))]    [ProvideProperty(“Dock”, typeof(ToolStripItem))]    class TableLayoutToolStrip : ToolStrip, IExtenderProvider {        public TableLayoutToolStrip() {            this.LayoutStyle = ToolStripLayoutStyle.Table;            RowCount = 3;            ColumnCount = 3;         }        …


Creating readonly controls – ComboBox, etc.

The following panel makes any control within it read-only (e.g. unresponsive to clicks/keyboard input) without turning it dark grey.  There is an alternate solution specifically for combobox as presented at the PDC.  Code is here.      public class ReadonlyControlHolder : Panel {         private bool readOnly = false;         public bool ReadOnly {            get {                return…


UseCompatibleTextRendering – Compatible with whaaaaaat?

There seems to be quite a bit of confusion around this little old flag that has cropped up in VS 2005.  In Windows Forms 2.0, we added support for drawing GDI text.  At first we had grandiose plans of poking and prodding at the DrawText API such that we could make it match up exactly…


How can I create a wrapping radio button / checkbox?

By default the RadioButton and CheckBox class take on the Button’s philosophy of AutoSizing – size to fit all contents on one line.  If you have an AutoSize=false RadioButton, and size it manually, you’ll notice that the text nicely wraps on the word breaks (i.e. spaces between words).  It seems that if we could just…


How do I get text to wrap in Windows Forms 2.0?

The fundamental problem in 1.1 When label is set to AutoSize = true, it measures as if all the text wants to be on one line.  In order to have multiple lines of text in 1.1, the AutoSize property cannot be used. Guessing in 1.1 When you drop a label on a form in version…