WinForms: Measure Text With No Padding
问题 In a WinForms app, I am trying to measure the size of some text I want to draw with no padding . Here's the closest I've gotten... protected override void OnPaint(PaintEventArgs e) { DrawIt(e.Graphics); } private void DrawIt(Graphics graphics) { var text = "123"; var font = new Font("Arial", 32); var proposedSize = new Size(int.MaxValue, int.MaxValue); var measuredSize = TextRenderer.MeasureText(graphics, text, font, proposedSize, TextFormatFlags.NoPadding); var rect = new Rectangle(100, 100,