From 5de50009d2c01e13c1c03a07d985cfdf82a18a19 Mon Sep 17 00:00:00 2001 From: YFdyh000 Date: Thu, 16 Apr 2020 07:06:33 +0800 Subject: [PATCH] fix bold measuring --- v2rayN/v2rayN/Base/ListViewFlickerFree.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/v2rayN/v2rayN/Base/ListViewFlickerFree.cs b/v2rayN/v2rayN/Base/ListViewFlickerFree.cs index 6785959b..5004e84a 100644 --- a/v2rayN/v2rayN/Base/ListViewFlickerFree.cs +++ b/v2rayN/v2rayN/Base/ListViewFlickerFree.cs @@ -18,24 +18,23 @@ namespace v2rayN.Base { try { - int count = this.Columns.Count; int MaxWidth = 0; Graphics graphics = this.CreateGraphics(); - Font font = this.Font; - ListViewItemCollection items = this.Items; string str; int width; this.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); - for (int i = 0; i < count; i++) + for (int i = 0; i < this.Columns.Count; i++) { - str = this.Columns[i].Text; - MaxWidth = this.Columns[i].Width; + ColumnHeader c = this.Columns[i]; + str = c.Text; + MaxWidth = c.Width; - foreach (ListViewItem item in items) + foreach (ListViewItem item in this.Items) { + Font font = item.SubItems[i].Font; str = item.SubItems[i].Text; width = (int)graphics.MeasureString(str, font).Width; if (width > MaxWidth) @@ -43,11 +42,7 @@ namespace v2rayN.Base MaxWidth = width; } } - if (i == 0) - { - this.Columns[i].Width = MaxWidth; - } - this.Columns[i].Width = MaxWidth; + c.Width = MaxWidth; } } catch { }