private void Item_LostFocus(object sender, EventArgs e) { if (selectedItem == sender) { selectedItem = null; } }
public void AddItem(ScLayer[] fieldElemLayers, ScListViewItem.ReLayoutEventHandler itemReLayoutEvent = null) { CreateItemLayoutTable(wrapper.controls.Count() + 1); int idx = wrapper.controls.Count(); int rowIdx = idx / colItemCount; int colIdx = idx % colItemCount; RectangleF r = itemLayoutTable.GetCellRect(rowIdx, colIdx); r = itemLayoutTable.TransToGlobalRect(r); ScListViewItem item = new ScListViewItem(fieldElemLayers); item.ReLayoutEvent += itemReLayoutEvent; item.listView = this; item.DirectionRect = r; item.GotFocus += Item_GotFocus; item.MouseHoverEvent += Item_MouseHoverEvent; item.LostFocus += Item_LostFocus; AddContentControl(item); item.Focus(); Refresh(); }
public void RemoveItem(ScListViewItem item) { ScListViewItem newSelectedItem = null; int selectedIdx = controls.IndexOf(selectedItem); if (selectedItem == item) { if (selectedIdx < wrapper.controls.Count() - 1) { newSelectedItem = (ScListViewItem)wrapper.controls.ElementAt(selectedIdx + 1); } else if (selectedIdx > 0) { newSelectedItem = (ScListViewItem)wrapper.controls.ElementAt(selectedIdx - 1); } } SuspendLayout(); RemoveContentControl(item); ResumeLayout(true); if (newSelectedItem != null) { newSelectedItem.Focus(); } Refresh(); }
private void Item_GotFocus(object sender, EventArgs e) { selectedItem = (ScListViewItem)sender; }
private void Item_MouseHoverEvent(object sender) { mouseHoverItem = (ScListViewItem)sender; }