diff options
Diffstat (limited to 'mcs/class')
3 files changed, 28 insertions, 14 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 9183d769fc1..a795c3cf8b5 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,10 @@ +2006-02-28 Mike Kestner <mkestner@novell.com> + + * ListView.cs: Add UpdateSelection internal method. Remove SelectItem + and set Selected instead. + * ListViewItem.cs: Call owner.UpdateSelection to manipulate the + collections. + 2006-02-28 Peter Dennis Bartok <pbartok@novell.com> * ComboBox.cs: Allow setting SelectedIndex to -1. Fixes #77665 diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs index 70ec71df299..551f6584f1e 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs @@ -911,18 +911,23 @@ namespace System.Windows.Forms } - void SelectItem (ListViewItem item) + internal void UpdateSelection (ListViewItem item) { - if (!CanMultiselect && SelectedItems.Count > 0) { - SelectedItems.Clear (); - SelectedIndices.list.Clear (); - } + if (item.Selected) { - if (!SelectedItems.Contains (item)) { - SelectedItems.list.Add (item); - SelectedIndices.list.Add (item.Index); + if (!CanMultiselect && SelectedItems.Count > 0) { + SelectedItems.Clear (); + SelectedIndices.list.Clear (); + } + + if (!SelectedItems.Contains (item)) { + SelectedItems.list.Add (item); + SelectedIndices.list.Add (item.Index); + } + } else { + SelectedItems.list.Remove (item); + SelectedIndices.list.Remove (item.Index); } - item.Selected = true; } private bool KeySearchString (KeyEventArgs ke) @@ -940,7 +945,7 @@ namespace System.Windows.Forms if (CultureInfo.CurrentCulture.CompareInfo.IsPrefix (Items[i].Text, keysearch_text, CompareOptions.IgnoreCase)) { SetFocusedItem (Items [i]); - SelectItem (items [i]); + items [i].Selected = true; EnsureVisible (i); break; } @@ -1040,7 +1045,7 @@ namespace System.Windows.Forms } if (index != -1) { - SelectItem (items [index]); + items [index].Selected = true; SetFocusedItem (items [index]); EnsureVisible (index); } @@ -1136,7 +1141,7 @@ namespace System.Windows.Forms if (clicked_item != null) { bool changed = !clicked_item.Selected; - SelectItem (clicked_item); + clicked_item.Selected = true;; // Only Raise the event if the selected item has changed if (changed) @@ -1169,7 +1174,7 @@ namespace System.Windows.Forms ListViewItem item = this.GetItemAt (hit.X, hit.Y); if (item != null) { - SelectItem (item); + item.Selected = true; // Raise the event this.OnSelectedIndexChanged (new EventArgs ()); } diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs index 6e5d38ef7fc..53aebae7984 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs @@ -273,8 +273,10 @@ namespace System.Windows.Forms selected = value; - if (owner != null) + if (owner != null) { + owner.UpdateSelection (this); Layout (); + } Invalidate (); } } |