I suppose that exist a known clarification about why those methods always return distinct sizes, but anyways I will explain the problem a little:
I've subclassed a Progressbar, when I try to get the size of the same text with the same font, I get distinct values, TextRenderer.MeasureTextgives me a rounded value of 13 height and 300 width while Graphics.MeasureString gives me a very precise height of 13,xxxxxx and a minor width of 275,xxxxxxx
Why happens that?.
I'm not doing nothing especial in the code, just I've tried to use both methods to compare whether it gives me the same result or not to decide which to use in my code.
The overload of TextRenderer.MeasureText that I've tried to use is:
TextRenderer.MeasureText(String, Font)
And the Graphics.MeasureString method expects the same parameters:
Graphics.MeasureString(String, Font)
TextRenderreturns aSize,MeasureStringreturnsSizeF. Depending on where you are putting the Text, one may be more appropriate than the other... the FONT arg is usually more likethisCtl.Fontso that it is accurate.ProgressBarRendererif you are drawing to one there might be internal margins defined which will alter your results. nevermind - there are none for it. TheCheckBoxRendergives you the size of the check and margin between it and the start of text.