protected virtual void OnItemDeselecting(ItemChangingEventArgs e) { if (ItemDeselecting != null) { ItemDeselecting(this, e); } }
private void ItemStateChanging(ref Message m, ref NMLISTVIEW nmlv) { if ((nmlv.uChanged & LVIF_STATE) == LVIF_STATE) { if ((nmlv.uOldState == LVIS_SELECTED) || //FROM ITEM (nmlv.uNewState == LVIS_UNSELECTED)) { if (m_cancel) { m.Result = new IntPtr(1); m_cancel = false; } else { if ((nmlv.uOldState == LVIS_SELECTED) && //FROM ITEM (nmlv.uNewState == LVIS_UNSELECTED)) { ItemChangingEventArgs e = new ItemChangingEventArgs(nmlv.iItem, this.Items[nmlv.iItem]); OnItemDeselecting(e); if (e.Cancel) { m.Result = new IntPtr(1); m_cancel = true; } } } } else if ((nmlv.uOldState == LVIS_UNSELECTED) || //TO ITEM (nmlv.uNewState == LVIS_SELECTED) || (nmlv.uNewState == LVIS_SELECTED_FOCUSED)) { if (m_cancel) { m.Result = new IntPtr(1); m_cancel = false; } } } }