/// <summary> /// 处理行单击。 /// </summary> /// <param name="info"></param> private void ProcessItemClick(TreeListHitTestInfo info) { var item = (TreeListItem)((VirtualTreeListItem)info.Element).Item; //按着ctrol切换选中状态 if (_controlPressed) { SelectItem(item, !item.Selected, false); } else if (_shiftPressed && _lastRowIndex != -1) { if (_lastRowIndex > _virMgr.Items.Count - 1) { return; } for (var i = SelectedItems.Count - 1; i >= 0; i--) { SelectedItems[i].SetSelected(false); } SelectedItems.InternalClear(); Invalidate(_bound.ItemBound); var start = _lastRowIndex; var end = item.Index; if (start > end) { start = end; end = _lastRowIndex; } for (var i = start; i <= end; i++) { if (!(_virMgr.Items[i].Item is TreeListItem t)) { continue; } t.SetSelected(true); SelectedItems.InternalAdd(t); } Invalidate(); RaiseItemSelectionChangedEvent(); } //选中且不是多选时,只触发单击事件 else if (item.Selected && SelectedItems.Count == 1) { RaiseItemClickEvent(item); return; } //选中当前行 else { SelectItem(item, true); HideEditor(); _lastRowIndex = item.Index; } RaiseItemClickEvent(item); }