// Selects this element void ISelectionItemProvider.Select() { // Make sure that the control is enabled if (!SafeNativeMethods.IsWindowEnabled(_hwnd)) { throw new ElementNotEnabledException(); } // simple case: object already selected - only works for single selection element if (!WindowsListView.MultiSelected(_hwnd) && WindowsListView.IsItemSelected(_hwnd, _item)) { return; } // Unselect all items. WindowsListView.UnselectAll(_hwnd); // Select the specified item. if (!WindowsListView.SelectItem(_hwnd, _item)) { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } }