Name

ControlStyles

Synopsis

This enumeration is used by Control.SetStyle() to enable or disable a variety of different features in a custom control.

Several features relate to the painting of the control. AllPaintingInWmPaint causes both the OnPaint() and OnPaintBackground() methods to be called during WM_PAINT handling, rather than WM_PAINT and WM_ERASEBACKGROUND as normal.

UserPaint indicates to the platform that you will be painting the control yourself, rather than relying on the operating system to do it for you (i.e., your control does not wrap a Win32 control and you therefore expect to handle WM_PAINT yourself).

DoubleBuffer enables automatic double buffering for your control. A back buffer is created before OnPaint() is called, and the System.Drawing.Graphics surface for that buffer is passed to your paint handler. When you complete your painting, the buffer is blitted to the window surface, dramatically reducing the amount of flicker that occurs when you paint, at the cost of one extra blit into the window, and potentially an awful lot of extra committed memory for the back buffer. To get double buffering to work properly, you should also set AllPaintingInWmPaint (to prevent two separate blits for the background and the foreground, which will induce flicker) and UserPaint.

SupportsTransparentBackColor allows you to set a back System.Drawing.Color with an Alpha value less than 255. Because standard Win32 controls do not really support true transparency, the default OnPaintBackground() ...

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.