diff --git a/docs/changes.txt b/docs/changes.txt index b7f0a31924..5bde916950 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -135,6 +135,7 @@ All (GUI): - Fixed incorrect layout width caching in wxHTML (Jeff Tupper). - wxHTML: preserve TAB characters when copying
 content to clipboard.
 - Set focus to wxCalendarCtrl when it is clicked.
+- Don't clear the list control when wxLC_[HV]RULES style is toggled.
 
 All (Unix):
 
diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp
index e238cfe8f9..060a54398d 100644
--- a/src/generic/listctrl.cpp
+++ b/src/generic/listctrl.cpp
@@ -5123,7 +5123,17 @@ void wxGenericListCtrl::SetSingleStyle( long style, bool add )
     else
         flag &= ~style;
 
-    SetWindowStyleFlag( flag );
+    // some styles can be set without recreating everything (as happens in
+    // SetWindowStyleFlag() which calls wxListMainWindow::DeleteEverything())
+    if ( !(style & ~(wxLC_HRULES | wxLC_VRULES)) )
+    {
+        Refresh();
+        wxWindow::SetWindowStyleFlag(flag);
+    }
+    else
+    {
+        SetWindowStyleFlag( flag );
+    }
 }
 
 void wxGenericListCtrl::SetWindowStyleFlag( long flag )