//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods // retrieve current ToggleState private ToggleState GetToggleState() { ListViewItem.CheckState current = (ListViewItem.CheckState)WindowsListView.GetCheckedState(_hwnd, _listviewItem); switch (current) { case ListViewItem.CheckState.NoCheckbox: { throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed)); } case ListViewItem.CheckState.Checked: { return(ToggleState.On); } case ListViewItem.CheckState.Unchecked: { return(ToggleState.Off); } } // developer defined custom values which cannot be interpret outside of the app's scope return(ToggleState.Indeterminate); }
// detect if given listviewitem has a checkbox internal static bool IsItemWithCheckbox(IntPtr hwnd, int item) { if (!WindowsListView.CheckBoxes(hwnd)) { return(false); } // this listview supports checkbox, detect if // current item has it return(CheckState.NoCheckbox != (CheckState)WindowsListView.GetCheckedState(hwnd, item)); }