Posts

Custom-drawn CheckBox and RadioButton

My take on a drop-in replacement for custom-drawn CheckBox and RadioButton controls:

Event handlers with multiple arguments

From C# 7.0 on, named tuple types make it possible to simplify the declaration and use of event handlers with multiple parameters.

SQLite-net, custom functions, and collections

It is not possible to define a custom function in SQLite-net that is able to use collections (sqlite does not work with managed code).

The code below presents an alternative that, although a hack, works.

ImageList fails to load the alpha channel

There is a bug in the ImageList component that ignores the alpha channel no matter the source format (.ico, .png) and distorts the display of images due to a failure to render transparency correctly. Thus the TabControl is so compromised in regards to icons in its tabs. The same applies to other controls that use ImageList.

This article provides a solution and explains the problem in more detail:

https://www.codeproject.com/articles/9142/adding-and-using-32-bit-alphablended-images-and-ic

To be able to use DrawImage in general, make sure to include the png as a resource and then load it as expected via var image = Properties.Resources.some_image

Otherwise, use ico files and DrawIcon

Increase the tab size in a user-drawn TabControl

By modifying the padding, it is possible to create additional space for multiple icons or other content.

https://docs.microsoft.com/en-us/windows/win32/controls/tab-controls#tab-size-and-position

https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setpadding

https://docs.microsoft.com/en-us/windows/win32/api/_controls/

This is particularly useful in a TabControl with SizeMode = FillToRight because setting ControlStyles.UserPaint to true in the constructor will cause the system to report the size of tabs to match only the text (i.e., the space required for icons is unaccounted for).

My take:

Remove horizontal scrollbar in a ListView

https://stackoverflow.com/a/2500089/1908746

My take:

Remove the focus rectangle of a control

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.showfocuscues?view=net-5.0

My take: