Privacy Policy
Best viewed with:

☕ Buy me a coffee
Mick Dohertys' .net Tips and Tricks - Tips / Miscelaneous Controls
Restrict the Minimum and Maximum Size of a UserControl.

The Following Code is based on an example originally posted by Jacob Grass.

  • VB Code
  • C# Code


Get Alpha Bitmap from 32 bit Icon.

Get rid of those ugly shadows.

  • VB Code
  • C# Code


Save the Image currently displayed in a PictureBox.

In the good old days (pre dotnet) a Picturebox had an Image property and a Picture property. The Picture property was the equivelant of today's Image property, whilst the Image property was the Image actually displayed in the Picturebox.
If you draw to a Picturebox in it's paint method then that drawing will persist in the picturebox, but if you try to save the resultant image, you will find that you won't save any of the extra drawing done in paint.
The following code will allow you to save the Image with all extra painting.

  • VB Code
  • C# Code


Draw 32 bit images from an Imagelist.

Useful for controls that don't have an imagelist property or for painting in your own custom control.
Note that pngs added to an imagelist will draw alpha with a blue tint so, if possible, add icons to the imagelist.
Also note that 32 bit images should be loaded into the imagelist at runtime or the imagelist will 'Flatten' the Alpha channel.

  • VB Code
  • C# Code

You'll also need the IconToAlphaBitmap() method shown above(Get Alpha Bitmap from 32 bit Icon.)