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