// Removes this element from the selection void ISelectionItemProvider.RemoveFromSelection() { // Make sure that the control is enabled if (!SafeNativeMethods.IsWindowEnabled(_hwnd)) { throw new ElementNotEnabledException(); } // simple case: item is not selected if (!WindowsListView.IsItemSelected(_hwnd, _item)) { return; } // object does not support multi-selection if (!WindowsListView.MultiSelected(_hwnd)) { IRawElementProviderSimple container = ((ISelectionItemProvider)this).SelectionContainer; bool selectionRequired = container != null ? ((ISelectionProvider)container).IsSelectionRequired : true; // For single selection containers that IsSelectionRequired == false a // RemoveFromSelection is valid. if (selectionRequired) { throw new InvalidOperationException(SR.Get(SRID.SelectionRequired)); } } // try to unselect the item if (!WindowsListView.UnSelectItem(_hwnd, _item)) { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } }