* ListView.cs: When the last item is focused and is removed,
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Sat, 6 Oct 2007 07:35:22 +0000 (07:35 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Sat, 6 Oct 2007 07:35:22 +0000 (07:35 -0000)
move the focus to the previous item (in Items order). This is what MS
does.
Fixes #330415.

2007-10-06  Carlos Alberto Cortez <calberto.cortez@gmail.com>

svn path=/trunk/mcs/; revision=87027

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs

index 0c0a8c0e97f3d7dd797772f0de09c7ec35ef1bb9..e9f7c8bfbaae5619f8b431433b4995536c666ed3 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-06  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * ListView.cs: When the last item is focused and is removed,
+       move the focus to the previous item (in Items order). This is what MS
+       does.
+       Fixes #330415.
+
 2007-10-06  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ListView.cs: In ListViewItemCollection, make Remove call RemoveAt,
index 47559f30b4458f4f5a262ef74a7c81fb2138d08c..b34eb00d0223dc49159445b9594704af46fb0645 100644 (file)
@@ -4843,6 +4843,10 @@ namespace System.Windows.Forms
 
                                bool selection_changed = false;
                                if (is_main_collection && owner != null) {
+
+                                       if (item.Focused && index + 1 == Count) // Last item
+                                               owner.SetFocusedItem (index == 0 ? -1 : index - 1);
+
                                        selection_changed = owner.SelectedIndices.Contains (index);
                                        owner.item_control.CancelEdit (item);
                                }