This is a preview version of Cyotek's blog and may be missing functionality and/or unstable. Please visit for the current version of the blog.
If you encounter any problems using this preview site, please contact us with the details.

Posts tagged with 'listbox'

Displaying text in an empty ListBox

c# winforms WM_PAINT listbox wm_erasebkgnd 3 Comments Downloads

While looking at ways of improving the UI of a dialog in an application, I wanted to display some status text in a ListBox control that was empty. The default Windows Forms ListBox (which uses the underlying native Win32 control) doesn't support this, but with a little effort we can extend the control.

When a Control receives either the WM_PAINT or WM_ERASEBKGND messages, it will check to see if the ControlStyles.UserPaint style is set. If set then the WM_PAINT message will cause the Paint event to be raised, and for WM_ERASEBKGND the PaintBackground event - but only if the the AllPaintingInWmPaint style is not set.

Read More

Dragging items in a ListBox control with visual insertion guides

c# winforms drag and drop insertion WM_PAINT listbox 2 Comments Downloads

In my last post, I described how to drag and drop items to reorder a ListView control. This time I'm going to describe the exact same technique, but this time for the more humble ListBox.

The code below assumes you are working in a new class named ListBox that inherits from System.Windows.Forms.ListBox.

Read More