From 307646d0a9f5d50f778c05d6f99c1aaf3af6bc28 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Thu, 26 Sep 2013 14:33:50 +0100 Subject: [PATCH] CP-6317: Importing from branch clearwater-ln. # HG changeset patch # User Konstantina Chremmou # Date 1377007835 -3600 # Node ID a1c6bcf2b4d3119cff54d87fb97bd2491c9d8f67 # Parent 41c2dfb11187cbc91b4f874b1df8c06524aad3c7 CA-113310: Corrected string measurement which was causing truncation on SC and a lot of white space on EN and JA versions. Signed-off-by: Konstantina Chremmou --- .../Controls/ComboBoxes/LongStringComboBox.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/XenAdmin/Controls/ComboBoxes/LongStringComboBox.cs b/XenAdmin/Controls/ComboBoxes/LongStringComboBox.cs index b65e7f1f1..be122180f 100644 --- a/XenAdmin/Controls/ComboBoxes/LongStringComboBox.cs +++ b/XenAdmin/Controls/ComboBoxes/LongStringComboBox.cs @@ -82,17 +82,17 @@ namespace XenAdmin.Controls { get { - using (Graphics graphics = CreateGraphics()) + int longest = 0; + foreach (var item in Items) { - int longest = 0; - foreach (var item in Items) - { - int stringLength = (int) graphics.MeasureString(item.ToString(), Font).Width; - if (stringLength > longest) - longest = stringLength; - } - return longest; + //CA-113310: use TextRenderer rather than Graphics to measure + //the string because it will be placed on a winforms control + //with the default UseCompatibleTextRendering value (false) + int stringLength = TextRenderer.MeasureText(item.ToString(), Font).Width; + if (stringLength > longest) + longest = stringLength; } + return longest; } }