/// <summary> /// Removes an item with the specified name from the collection. /// </summary> /// <param name="name"></param> public void Remove(string name) { ListViewGridItem _item = GetItemByName(name); if (_item != null) { Remove(_item); } }
protected override void OnRemove(int index, object value) { ListViewGridItem _item = (ListViewGridItem)List[index]; if (Contains(_item.Name)) { _collectiontable.Remove(_item.Name); } base.OnRemove(index, value); }
private ListViewGridItem GetItemByName(string name) { ListViewGridItem _item = null; if (_collectiontable.ContainsKey(name)) { _item = (ListViewGridItem)_collectiontable[name]; } return(_item); }
private void trvwModules_AfterNodeSelect(object sender, DevComponents.AdvTree.AdvTreeNodeEventArgs e) { if (_nodesloading) { return; } if (e.Node == null) { return; } _selectedsubmodule = SubModule.None; if (e.Node.Nodes.Count > 0) { DisableButtons(); grdRecords.Hide(); if (lstvwRecords.Redraw) { lstvwRecords.BeginUpdate(); } lstvwRecords.ImageList = _images32; lstvwRecords.Show(); lstvwRecords.ListItems.Clear(); for (int i = 0; i <= (e.Node.Nodes.Count - 1); i++) { ListViewGridItem _item = new ListViewGridItem(e.Node.Nodes[i].Name, e.Node.Nodes[i].Text.Replace(" ", "\n"), e.Node.Nodes[i].Name); _item.Tag = e.Node.Nodes[i].Tag; lstvwRecords.ListItems.Add(_item); } while (!lstvwRecords.Redraw) { lstvwRecords.EndUpdate(); } } else { if (VisualBasic.IsNumeric(e.Node.Tag)) { if (VisualBasic.CInt(e.Node.Tag) > 0) { try { _selectedsubmodule = (SubModule)e.Node.Tag; } catch { _selectedsubmodule = SubModule.None; } grdRecords.Show(); lstvwRecords.Hide(); InitializeDataSource(); } } } }
/// <summary> /// Removes the specified item from the collection. /// </summary> /// <param name="item"></param> public void Remove(ListViewGridItem item) { if (Contains(item.Name)) { _collectiontable.Remove(item.Name); } if (Contains(item)) { List.Remove(item); } if (_listview != null) { _listview.InitializeListViewItems(); } }
/// <summary> /// Adds a new item into the collection. /// </summary> /// <param name="item"></param> /// <returns></returns> public int Add(ListViewGridItem item) { if (_collectiontable.ContainsKey(item.Name)) { throw new InvalidOperationException("Item names should not match existing names within the collection."); } _collectiontable.Add(item.Name, item); int _index = List.Add(item); if (_listview != null) { _listview.InitializeListViewItems(); } return(_index); }
/// <summary> /// Adds a new item into the collection. /// </summary> /// <param name="name"></param> /// <param name="text"></param> /// <param name="imagekey"></param> /// <returns></returns> public ListViewGridItem Add(string name, string text, string imagekey) { if (_collectiontable.ContainsKey(name)) { throw new InvalidOperationException("Item names should not match existing names within the collection."); } ListViewGridItem _item = new ListViewGridItem(name, text, imagekey); _item.SetOwner(_listview); int _index = List.Add(_item); _collectiontable.Add(name, _item); if (_listview != null) { _listview.InitializeListViewItems(); } return((ListViewGridItem)List[_index]); }
private void ListViewGrid_BeforeSelChange(object sender, RangeEventArgs e) { if (!Redraw) { return; } try { int _row = e.NewRange.BottomRow; int _col = e.NewRange.RightCol; if (_row >= Rows.Fixed && _row <= (Rows.Count - 1)) { if (_col >= Cols.Fixed && _col <= (Cols.Count - 1)) { object _userdata = GetUserData(_row, _col); if (Materia.IsNullOrNothing(_userdata)) { e.Cancel = true; } else { if (!(_userdata is ListViewGridItem)) { e.Cancel = true; } else { _selectedlistitem = (ListViewGridItem)_userdata; ListViewGridSelectionEventArgs _args = new ListViewGridSelectionEventArgs(_selectedlistitem); OnSelectedListItemChanged(_args); } } } } } catch { } }
/// <summary> /// Creates a new instance of ListViewGridSelectionEventArgs. /// </summary> /// <param name="item"></param> public ListViewGridSelectionEventArgs(ListViewGridItem item) { _listitem = item; }
/// <summary> /// Validates whether the specified item already exists within the collection. /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Contains(ListViewGridItem item) { return(List.Contains(item)); }
public void InitializeListViewItems() { this.ClearRowsAndColumns(); KeyActionTab = KeyActionEnum.MoveAcross; KeyActionEnter = KeyActionEnum.None; SelectionMode = SelectionModeEnum.Cell; Styles.Focus.BackgroundImage = Properties.Resources.GridTile; Styles.Focus.BackgroundImageLayout = ImageAlignEnum.Stretch; Styles.Highlight.BackgroundImage = Properties.Resources.GridTile; Styles.Highlight.BackgroundImageLayout = ImageAlignEnum.Stretch; Styles.Normal.Border.Style = BorderStyleEnum.None; Styles.Normal.Border.Color = Color.Transparent; Styles.Normal.ImageAlign = ImageAlignEnum.CenterTop; Styles.Normal.TextAlign = TextAlignEnum.CenterCenter; Styles.Editor.Border.Style = BorderStyleEnum.None; Styles.Editor.Border.Color = Color.Transparent; int _colcounts = (Size.Width / _defaulttilesize.Width); int _rowcounts = (Size.Height / _defaulttilesize.Height); ColumnCollection _cols = Cols; RowCollection _rows = Rows; _cols.Fixed = 1; _cols.Count = _colcounts; _rows.Fixed = 1; _rows.Count = _rowcounts; _cols[_cols.Fixed - 1].Visible = false; _rows[_rows.Fixed - 1].Visible = false; int _currow = _rows.Fixed; int _curcol = _cols.Fixed; for (int i = 0; i <= (ListItems.Count - 1); i++) { ListViewGridItem _item = ListItems[i]; if (_imagelist != null) { if (_imagelist.Images.ContainsKey(_item.ImageKey)) { Image _image = _imagelist.Images[_item.ImageKey].ResizeImage(32, 32); SetCellImage(_currow, _curcol, _image); } } SetData(_currow, _curcol, _item.Text); SetUserData(_currow, _curcol, _item); if ((_curcol + 1) < _colcounts) { _curcol += 1; } else { _currow += 1; _curcol = _cols.Fixed; } } for (int i = _cols.Fixed; i <= (_cols.Count - 1); i++) { _cols[i].Width = _defaulttilesize.Width; } for (int i = _rows.Fixed; i <= (_rows.Count - 1); i++) { _rows[i].Height = _defaulttilesize.Height; } }