tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Create icon from text

10 Jul 2005 1 mins .NET

Here’s easy function for creating icon from string. I’m using it for traybar icon and for showing some usefull information on my notebook, i.e. the battery life in minutes.

private static System.Drawing.Icon DrawIcon(string IconMessage)
	Icon result = null;
		Bitmap b = new Bitmap(16,16);
		Graphics g = Graphics.FromImage((Image)b);
			new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel),
			new SolidBrush(System.Drawing.Color.Black),
 		result = Icon.FromHandle(b.GetHicon());
	catch (Exception e)
	return result;

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at