OSDN Git Service

#27315 キャッシュの一覧の削除でフリーズしたかのように時間がかかる問題の暫定対応(注意書きの追加、非効率的な処理の改善)
[wptscs/wpts.git] / Wptscs / ConfigForm.cs
index 818393a..64b215a 100644 (file)
@@ -236,15 +236,19 @@ namespace Honememo.Wptscs
             // ※ ただし全列が空(新規行など)の場合は無視
             if (e.RowIndex >= 0)
             {
-                string value = FormUtils.ToString(this.dataGridViewItems["ColumnTimestamp", e.RowIndex]);
-                if (String.IsNullOrWhiteSpace(value)
-                    && !this.IsEmptyDataGridViewItemsRow(this.dataGridViewItems.Rows[e.RowIndex]))
+                DataGridViewRow row = this.dataGridViewItems.Rows[e.RowIndex];
+                if (String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnTimestamp"]))
+                    && !this.IsEmptyDataGridViewItemsRow(row))
                 {
-                    this.dataGridViewItems.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Bisque;
+                    // 背景色を変更
+                    row.DefaultCellStyle.BackColor = Color.Bisque;
                 }
-                else
+                else if (row.InheritedStyle.BackColor != this.dataGridViewItems.DefaultCellStyle.BackColor)
                 {
-                    this.dataGridViewItems.Rows[e.RowIndex].DefaultCellStyle.BackColor = this.dataGridViewItems.DefaultCellStyle.BackColor;
+                    // 背景色を戻す
+                    // ※ DefaultCellStyleプロパティにアクセスしたタイミングでインスタンスが
+                    //    作成されてしまうため、InheritedStyleを調べて変更が必要な場合だけアクセス
+                    row.DefaultCellStyle.BackColor = this.dataGridViewItems.DefaultCellStyle.BackColor;
                 }
             }
         }