using System; using System.ComponentModel; using System.Drawing.Design; using DevComponents.DotNetBar.SuperGrid.Primitives; namespace DevComponents.DotNetBar.SuperGrid { /// /// Represents the collection of grid cells. /// [Editor("DevComponents.SuperGrid.Design.GridCellCollectionEditor, DevComponents.SuperGrid.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=26d81176cfa2b486", typeof(UITypeEditor))] public class GridCellCollection : CustomCollection { #region Indexer (string) /// /// Gets or sets item at ColumnName index /// /// Name of Column containing the cell public GridCell this[string columnName] { get { GridCell cell = FindCellItem(columnName); if (cell != null) return (Items[cell.ColumnIndex]); return (null); } set { GridCell cell = FindCellItem(columnName); if (cell == null) throw new Exception("Column \"" + columnName + "\" not found."); Items[cell.ColumnIndex] = value; } } #endregion #region Indexer (Column) /// /// Gets or sets item at Column index /// /// Column containing the cell public GridCell this[GridColumn column] { get { return (Items[column.ColumnIndex]); } set { Items[column.ColumnIndex] = value; } } #endregion #region FindCellItem private GridCell FindCellItem(string columnName) { if (string.IsNullOrEmpty(columnName) == true) throw new Exception("Invalid Column Name."); foreach (GridCell cell in Items) { GridColumn col = cell.GridColumn; if (col == null) break; if (columnName.Equals(col.Name) == true) return (cell); } return (null); } #endregion } }