article

Painting the borders of a custom control using WM_NCPAINT

Using the `WM_NCPAINT` and `WM_NCCALCSIZE` messages in order to create and paint a non-client region for a C# WinForms custom control

avatar
Richard Moss
article

Creating a custom single-axis scrolling control in WinForms

A article which describes how to create a custom control that supports scrolling on a single axis.

avatar
Richard Moss
article

Setting tab stops in a Windows Forms TextBox control

The Windows Forms `TextBox` control doesn't offer an out of the box method for setting tabstops within the control, this article describes how to achieve this via p/invoke.

avatar
Richard Moss
article

Using message filters in Windows Forms applications

An overview of how to use the `IMessageFilter` interface to intercept Windows Messages within your application.

avatar
Richard Moss
article

Displaying multi-page tiff files using the ImageBox control and C#

A brief article showing how to display individual pages from a multi-page tiff file in the ImageBox control.

avatar
Richard Moss
article

Aligning Windows Forms custom controls to text baselines using C#

One of the nice things about the Visual Studio WinForms designers are the guidelines it draws onto design surfaces, aiding you in perfectly positioning your controls. These guidelines are known internally as snap lines, and by default each visual component inheriting from `Control` gets four of these, representing the values of the control's `Margin` property. However, this default designer doesn't include an implementation for the `BaseLine` snap line, which is used to align controls via their contained text. This article shows how to create a custom designer to allow your controls to easily include this alignment option.

avatar
Richard Moss
article

Adding keyboard accelerators and visual cues to a WinForms control

Some weeks ago I was trying to make parts of WebCopy's UI a little bit simpler via the expedient of hiding some of the more advanced (and consequently less used) options. And to do this, I created a basic toggle panel control. This worked rather nicely, and while writing it I thought I'd write a short article on adding keyboard support to WinForm controls.

avatar
Richard Moss
article

Hosting a ColorGrid control in a ToolStrip

The `ColorGrid` control is a fairly useful control for selecting from a predefined list of colours. However, it can take up quite a bit of screen real estate depending on how many colours it contains. This article describes how you can host a `ColorGrid` in a standard `ToolStrip` control, providing access to both the `ColorGrid` and the `ColorPickerDialog`, with some custom painting to show the active colour on the button to round it off.

avatar
Richard Moss
article

Adding Double Click support to the ComboBox control

I was recently using a `ComboBox` control with the `DropDownStyle` set to `Simple`, effectively turning into a combined text box and list box. However, when I wanted an action to occur on double clicking an item in the list I found that the control doesn't actually offer double click support. I suppose I should have just ripped out the combo box at that point and went with dedicated controls but instead I decided to extend `ComboBox` to support double clicks.

avatar
Richard Moss
article

Dragging items in a ListBox control with visual insertion guides

In my last post, I described how to [drag and drop items to reorder a `ListView` control](/blog/dragging-items-in-a-listview-control-with-visual-insertion-guides). This time I'm going to describe the exact same technique, but this time for the more humble `ListBox`.

avatar
Richard Moss
article

Dragging items in a ListView control with visual insertion guides

I can't remember when it was I first saw something being dragged with an insertion mark for guidance. Whenever it was, it was a long long time ago and I'm just catching up now. This article describes how to extend a `ListView` control to allow the items within it to be reordered, using insertion guides.

avatar
Richard Moss