How to compute the correct width of a digit in pixels?

Small adjustments are required to make this work as intended: TextRenderingHint.ClearTypeGridFit gives a better result when rendering the Text. It’s more precise and works well with the grid-fitting nature of Graphics.DrawString. See the notes you can find in the answer linked below for more informations on this matter. StringFormat alignment in both horizontal and vertical … Read more

How to eliminate flicker in Windows.Forms custom control when scrolling?

You could try putting the following in your constructor after the InitiliseComponent call. SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); EDIT: If you’re giving this a go, if you can, remove your own double buffering code and just have the control draw itself in response to the appropriate virtual methods being called.

How to create a User Control with rounded corners?

If you want really round corner and not only transparent trick you can use this example: private int radius = 20; [DefaultValue(20)] public int Radius { get { return radius; } set { radius = value; this.RecreateRegion(); } } [System.Runtime.InteropServices.DllImport(“gdi32.dll”)] private static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int … Read more

Drawing a Long String on to a Bitmap results in Drawing Issues

When drawing a string of characters (ASCII or a form of Unicode encoded symbols) using Graphics.DrawString() with a fixed sized Font, the resulting graphics appear to generate a sort of grid, degrading the visual quality of the rendering. A solution is to substitute the GDI+ Graphics methods with the GDI methods, using TextRenderer.MeasureText() and TextRenderer.DrawText(). … Read more