private void listBoxEx1_Click(object sender, EventArgs e) { int idx = listBoxEx1.SelectedIndex; if (idx != -1) { ListBoxExRow row = listBoxEx1.Items[idx]; if (row.ToString().EndsWith("ListBoxExRowText")) { MessageBox.Show(string.Format("click:{0}", (row as ListBoxExRowText).Text)); return; } } }
public void RemoveItem(ListBoxExRow item) { _items.Remove(item); _rowsHeight = 0; for (int i = 0; i < _items.Count; i++) { _rowsHeight += ((ListBoxExRow)_items[i]).Height; } this.Refresh(); }
public void InsertItem(ListBoxExRow item, int idx) { item.Width = this.Width; _rowsHeight += item.Height; _items.Insert(idx, item); int tmpheight = 0; for (int i = 0; i < _items.Count; i++) { if (tmpheight + ((ListBoxExRow)_items[i]).Height > _scrollTop + Height) { if (i > idx) { _scrollTop += item.Height; } break; } tmpheight += ((ListBoxExRow)_items[i]).Height; } this.Refresh(); }
public void AddItem(ListBoxExRow item) { item.Width = this.Width; _rowsHeight += item.Height; _items.Add(item); this.Refresh(); }