public void AddAt (int index, DataGridColumn column) { columns.Insert (index, column); column.Set_Owner (owner); if (track) ((IStateManager) column).TrackViewState (); }
public void Add (DataGridColumn column) { columns.Add (column); column.Set_Owner (owner); if (track) ((IStateManager) column).TrackViewState (); }
public int IndexOf(DataGridColumn column) { if (column != null) { return this.columns.IndexOf(column); } return -1; }
public void AddAt(int index, DataGridColumn column) { if (column == null) { throw new ArgumentNullException("column"); } if (index == -1) { this.columns.Add(column); } else { this.columns.Insert(index, column); } column.SetOwner(this.owner); if (this.marked) { ((IStateManager) column).TrackViewState(); } this.OnColumnsChanged(); }
private void setStyle(DataGridColumn c, ListItemType tp) { switch (tp) { case ListItemType.Header: { c.HeaderStyle.VerticalAlign = VerticalAlign.Top; c.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; c.HeaderStyle.Wrap = false; return; } case ListItemType.Footer: { c.FooterStyle.VerticalAlign = VerticalAlign.Top; c.FooterStyle.HorizontalAlign = HorizontalAlign.Right; c.FooterStyle.Wrap = false; return; } case ListItemType.Item: { c.ItemStyle.VerticalAlign = VerticalAlign.Top; c.ItemStyle.HorizontalAlign = HorizontalAlign.Right; c.ItemStyle.Wrap = false; return; } } }
public void Remove(DataGridColumn column) { }
public void AddAt(int index, DataGridColumn column) { }
/// <devdoc> /// Creates the set of columns to be used to build up the control /// hierarchy. /// When AutoGenerateColumns is true, the columns are created to match the /// datasource and are appended to the set of columns defined in the Columns /// collection. /// </devdoc> protected virtual ArrayList CreateColumnSet(PagedDataSource dataSource, bool useDataSource) { ArrayList columnsArray = new ArrayList(); DataGridColumn[] definedColumns = new DataGridColumn[Columns.Count]; Columns.CopyTo(definedColumns, 0); int i; for (i = 0; i < definedColumns.Length; i++) columnsArray.Add(definedColumns[i]); if (AutoGenerateColumns == true) { ArrayList autoColumns = null; if (useDataSource) { autoColumns = CreateAutoGeneratedColumns(dataSource); autoGenColumnsArray = autoColumns; } else { autoColumns = autoGenColumnsArray; } if (autoColumns != null) { int autoColumnCount = autoColumns.Count; for (i = 0; i < autoColumnCount; i++) columnsArray.Add(autoColumns[i]); } } return columnsArray; }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected virtual void InitializeItem(DataGridItem item, DataGridColumn[] columns) { TableCellCollection cells = item.Cells; for (int i = 0; i < columns.Length; i++) { TableCell cell; if ((item.ItemType == ListItemType.Header) && UseAccessibleHeader) { cell = new TableHeaderCell(); cell.Attributes["scope"] = "col"; } else { cell = new TableCell(); } columns[i].InitializeCell(cell, i, item.ItemType); cells.Add(cell); } }
/// <internalonly/> /// <devdoc> /// <para>Creates the control hierarchy that is used to render the DataGrid. /// This is called whenever a control hierarchy is needed and the /// ChildControlsCreated property is false. /// The implementation assumes that all the children in the controls /// collection have already been cleared.</para> /// </devdoc> protected override void CreateControlHierarchy(bool useDataSource) { pagedDataSource = CreatePagedDataSource(); IEnumerator dataSource = null; int count = -1; int totalCount = -1; ArrayList keysArray = DataKeysArray; ArrayList columnsArray = null; if (itemsArray != null) { itemsArray.Clear(); } else { itemsArray = new ArrayList(); } itemsCollection = null; if (useDataSource == false) { // ViewState must have a non-null value for ItemCount because we check for // this in CreateChildControls count = (int)ViewState[BaseDataList.ItemCountViewStateKey]; totalCount = (int)ViewState[DataSourceItemCountViewStateKey]; if (count != -1) { if (pagedDataSource.IsCustomPagingEnabled) { pagedDataSource.DataSource = new DummyDataSource(count); } else { pagedDataSource.DataSource = new DummyDataSource(totalCount); } dataSource = pagedDataSource.GetEnumerator(); columnsArray = CreateColumnSet(null, false); itemsArray.Capacity = count; } } else { keysArray.Clear(); IEnumerable realDataSource = GetData(); if (realDataSource != null) { ICollection collection = realDataSource as ICollection; if ((collection == null) && pagedDataSource.IsPagingEnabled && !pagedDataSource.IsCustomPagingEnabled) { throw new HttpException(SR.GetString(SR.DataGrid_Missing_VirtualItemCount, ID)); } pagedDataSource.DataSource = realDataSource; if (pagedDataSource.IsPagingEnabled) { if ((pagedDataSource.CurrentPageIndex < 0) || (pagedDataSource.CurrentPageIndex >= pagedDataSource.PageCount)) { throw new HttpException(SR.GetString(SR.Invalid_CurrentPageIndex)); } } columnsArray = CreateColumnSet(pagedDataSource, useDataSource); if (storedDataValid) { dataSource = storedData; } else { dataSource = pagedDataSource.GetEnumerator(); } if (collection != null) { int initialCapacity = pagedDataSource.Count; keysArray.Capacity = initialCapacity; itemsArray.Capacity = initialCapacity; } } } int columnCount = 0; if (columnsArray != null) columnCount = columnsArray.Count; if (columnCount > 0) { DataGridColumn[] displayColumns = new DataGridColumn[columnCount]; columnsArray.CopyTo(displayColumns, 0); Table table = new ChildTable(String.IsNullOrEmpty(ID) ? null : ClientID); Controls.Add(table); for (int c = 0; c < displayColumns.Length; c++) { displayColumns[c].Initialize(); } TableRowCollection rows = table.Rows; DataGridItem item; ListItemType itemType; int index = 0; int dataSetIndex = 0; string keyField = DataKeyField; bool storeKeys = (useDataSource && (keyField.Length != 0)); bool createPager = pagedDataSource.IsPagingEnabled; int editItemIndex = EditItemIndex; int selectedItemIndex = SelectedIndex; if (pagedDataSource.IsPagingEnabled) dataSetIndex = pagedDataSource.FirstIndexInPage; count = 0; if (createPager) { // top pager CreateItem(-1, -1, ListItemType.Pager, false, null, displayColumns, rows, pagedDataSource); } CreateItem(-1, -1, ListItemType.Header, useDataSource, null, displayColumns, rows, null); if (storedDataValid && (firstDataItem != null)) { if (storeKeys) { object keyValue = DataBinder.GetPropertyValue(firstDataItem, keyField); keysArray.Add(keyValue); } itemType = ListItemType.Item; if (index == editItemIndex) itemType = ListItemType.EditItem; else if (index == selectedItemIndex) itemType = ListItemType.SelectedItem; item = CreateItem(0, dataSetIndex, itemType, useDataSource, firstDataItem, displayColumns, rows, null); itemsArray.Add(item); count++; index++; dataSetIndex++; storedDataValid = false; firstDataItem = null; } while (dataSource.MoveNext()) { object dataItem = dataSource.Current; if (storeKeys) { object keyValue = DataBinder.GetPropertyValue(dataItem, keyField); keysArray.Add(keyValue); } itemType = ListItemType.Item; if (index == editItemIndex) itemType = ListItemType.EditItem; else if (index == selectedItemIndex) itemType = ListItemType.SelectedItem; else if (index % 2 != 0) { itemType = ListItemType.AlternatingItem; } item = CreateItem(index, dataSetIndex, itemType, useDataSource, dataItem, displayColumns, rows, null); itemsArray.Add(item); count++; dataSetIndex++; index++; } CreateItem(-1, -1, ListItemType.Footer, useDataSource, null, displayColumns, rows, null); if (createPager) { // bottom pager CreateItem(-1, -1, ListItemType.Pager, false, null, displayColumns, rows, pagedDataSource); } } if (useDataSource) { // save the number of items and pages contained in the DataGrid for use in round-trips if (dataSource != null) { ViewState[BaseDataList.ItemCountViewStateKey] = count; if (pagedDataSource.IsPagingEnabled) { ViewState["PageCount"] = pagedDataSource.PageCount; ViewState[DataSourceItemCountViewStateKey] = pagedDataSource.DataSourceCount; } else { ViewState["PageCount"] = 1; ViewState[DataSourceItemCountViewStateKey] = count; } } else { ViewState[BaseDataList.ItemCountViewStateKey] = -1; ViewState[DataSourceItemCountViewStateKey] = -1; ViewState["PageCount"] = 0; } } pagedDataSource = null; }
///<summary> /// UnDocumented method /// </summary> protected virtual ArrayList CreateColumnSet(PagedDataSource source, bool useDataSource) { DataGridColumn[] cols = new DataGridColumn [Columns.Count]; Columns.CopyTo (cols, 0); ArrayList l_columns = new ArrayList (); foreach (DataGridColumn current in cols) l_columns.Add (current); if (AutoGenerateColumns) { ArrayList auto_columns = null; if (useDataSource) { auto_columns = AutoCreateColumns (source); autoGenColsArrayList = auto_columns; } else { auto_columns = autoGenColsArrayList; } if (auto_columns != null && auto_columns.Count > 0) l_columns.AddRange (auto_columns); } return l_columns; }
protected internal override void PrepareControlHierarchy() { if (this.Controls.Count != 0) { Table table = (Table) this.Controls[0]; table.CopyBaseAttributes(this); table.Caption = this.Caption; table.CaptionAlign = this.CaptionAlign; if (base.ControlStyleCreated) { table.ApplyStyle(base.ControlStyle); } else { table.GridLines = GridLines.Both; table.CellSpacing = 0; } TableRowCollection rows = table.Rows; int count = rows.Count; if (count != 0) { int num2 = this.Columns.Count; DataGridColumn[] array = new DataGridColumn[num2]; if (num2 > 0) { this.Columns.CopyTo(array, 0); } Style s = null; if (this.alternatingItemStyle != null) { s = new TableItemStyle(); s.CopyFrom(this.itemStyle); s.CopyFrom(this.alternatingItemStyle); } else { s = this.itemStyle; } int num3 = 0; bool flag = true; for (int i = 0; i < count; i++) { Style style2; Style style3; TableCellCollection cells; DataGridItem item = (DataGridItem) rows[i]; switch (item.ItemType) { case ListItemType.Header: { if (this.ShowHeader) { break; } item.Visible = false; continue; } case ListItemType.Footer: { if (this.ShowFooter) { goto Label_016A; } item.Visible = false; continue; } case ListItemType.Item: item.MergeStyle(this.itemStyle); goto Label_029E; case ListItemType.AlternatingItem: item.MergeStyle(s); goto Label_029E; case ListItemType.SelectedItem: style2 = new TableItemStyle(); if ((item.ItemIndex % 2) == 0) { goto Label_021D; } style2.CopyFrom(s); goto Label_022A; case ListItemType.EditItem: style3 = new TableItemStyle(); if ((item.ItemIndex % 2) == 0) { goto Label_025F; } style3.CopyFrom(s); goto Label_026C; case ListItemType.Pager: { if (this.pagerStyle.Visible) { goto Label_0196; } item.Visible = false; continue; } default: goto Label_029E; } if (this.headerStyle != null) { item.MergeStyle(this.headerStyle); } goto Label_029E; Label_016A: item.MergeStyle(this.footerStyle); goto Label_029E; Label_0196: if (i == 0) { if (this.pagerStyle.IsPagerOnTop) { goto Label_01CE; } item.Visible = false; continue; } if (!this.pagerStyle.IsPagerOnBottom) { item.Visible = false; continue; } Label_01CE: item.MergeStyle(this.pagerStyle); goto Label_029E; Label_021D: style2.CopyFrom(this.itemStyle); Label_022A: style2.CopyFrom(this.selectedItemStyle); item.MergeStyle(style2); goto Label_029E; Label_025F: style3.CopyFrom(this.itemStyle); Label_026C: if (item.ItemIndex == this.SelectedIndex) { style3.CopyFrom(this.selectedItemStyle); } style3.CopyFrom(this.editItemStyle); item.MergeStyle(style3); Label_029E: cells = item.Cells; int num5 = cells.Count; if ((num2 > 0) && (item.ItemType != ListItemType.Pager)) { int num6 = num5; if (num2 < num5) { num6 = num2; } for (int j = 0; j < num6; j++) { if (!array[j].Visible) { cells[j].Visible = false; continue; } if ((item.ItemType == ListItemType.Item) && flag) { num3++; } Style headerStyleInternal = null; switch (item.ItemType) { case ListItemType.Header: headerStyleInternal = array[j].HeaderStyleInternal; break; case ListItemType.Footer: headerStyleInternal = array[j].FooterStyleInternal; break; default: headerStyleInternal = array[j].ItemStyleInternal; break; } cells[j].MergeStyle(headerStyleInternal); } if (item.ItemType == ListItemType.Item) { flag = false; } } } if (((this.Items.Count > 0) && (num3 != this.Items[0].Cells.Count)) && this.AllowPaging) { for (int k = 0; k < count; k++) { DataGridItem item2 = (DataGridItem) rows[k]; if ((item2.ItemType == ListItemType.Pager) && (item2.Cells.Count > 0)) { item2.Cells[0].ColumnSpan = num3; } } } } } }
protected override void CreateControlHierarchy(bool useDataSource) { this.pagedDataSource = this.CreatePagedDataSource(); IEnumerator storedData = null; int dataItemCount = -1; int num2 = -1; ArrayList dataKeysArray = base.DataKeysArray; ArrayList list2 = null; if (this.itemsArray != null) { this.itemsArray.Clear(); } else { this.itemsArray = new ArrayList(); } this.itemsCollection = null; if (!useDataSource) { dataItemCount = (int) this.ViewState["_!ItemCount"]; num2 = (int) this.ViewState["_!DataSourceItemCount"]; if (dataItemCount != -1) { if (this.pagedDataSource.IsCustomPagingEnabled) { this.pagedDataSource.DataSource = new DummyDataSource(dataItemCount); } else { this.pagedDataSource.DataSource = new DummyDataSource(num2); } storedData = this.pagedDataSource.GetEnumerator(); list2 = this.CreateColumnSet(null, false); this.itemsArray.Capacity = dataItemCount; } } else { dataKeysArray.Clear(); IEnumerable data = this.GetData(); if (data != null) { ICollection is2 = data as ICollection; if (((is2 == null) && this.pagedDataSource.IsPagingEnabled) && !this.pagedDataSource.IsCustomPagingEnabled) { throw new HttpException(System.Web.SR.GetString("DataGrid_Missing_VirtualItemCount", new object[] { this.ID })); } this.pagedDataSource.DataSource = data; if (this.pagedDataSource.IsPagingEnabled && ((this.pagedDataSource.CurrentPageIndex < 0) || (this.pagedDataSource.CurrentPageIndex >= this.pagedDataSource.PageCount))) { throw new HttpException(System.Web.SR.GetString("Invalid_CurrentPageIndex")); } list2 = this.CreateColumnSet(this.pagedDataSource, useDataSource); if (this.storedDataValid) { storedData = this.storedData; } else { storedData = this.pagedDataSource.GetEnumerator(); } if (is2 != null) { int count = this.pagedDataSource.Count; dataKeysArray.Capacity = count; this.itemsArray.Capacity = count; } } } int num4 = 0; if (list2 != null) { num4 = list2.Count; } if (num4 > 0) { DataGridItem item; ListItemType editItem; DataGridColumn[] array = new DataGridColumn[num4]; list2.CopyTo(array, 0); Table child = new ChildTable(string.IsNullOrEmpty(this.ID) ? null : this.ClientID); this.Controls.Add(child); for (int i = 0; i < array.Length; i++) { array[i].Initialize(); } TableRowCollection rows = child.Rows; int itemIndex = 0; int dataSourceIndex = 0; string dataKeyField = this.DataKeyField; bool flag = useDataSource && (dataKeyField.Length != 0); bool isPagingEnabled = this.pagedDataSource.IsPagingEnabled; int editItemIndex = this.EditItemIndex; int selectedIndex = this.SelectedIndex; if (this.pagedDataSource.IsPagingEnabled) { dataSourceIndex = this.pagedDataSource.FirstIndexInPage; } dataItemCount = 0; if (isPagingEnabled) { this.CreateItem(-1, -1, ListItemType.Pager, false, null, array, rows, this.pagedDataSource); } this.CreateItem(-1, -1, ListItemType.Header, useDataSource, null, array, rows, null); if (this.storedDataValid && (this.firstDataItem != null)) { if (flag) { object propertyValue = DataBinder.GetPropertyValue(this.firstDataItem, dataKeyField); dataKeysArray.Add(propertyValue); } editItem = ListItemType.Item; if (itemIndex == editItemIndex) { editItem = ListItemType.EditItem; } else if (itemIndex == selectedIndex) { editItem = ListItemType.SelectedItem; } item = this.CreateItem(0, dataSourceIndex, editItem, useDataSource, this.firstDataItem, array, rows, null); this.itemsArray.Add(item); dataItemCount++; itemIndex++; dataSourceIndex++; this.storedDataValid = false; this.firstDataItem = null; } while (storedData.MoveNext()) { object current = storedData.Current; if (flag) { object obj4 = DataBinder.GetPropertyValue(current, dataKeyField); dataKeysArray.Add(obj4); } editItem = ListItemType.Item; if (itemIndex == editItemIndex) { editItem = ListItemType.EditItem; } else if (itemIndex == selectedIndex) { editItem = ListItemType.SelectedItem; } else if ((itemIndex % 2) != 0) { editItem = ListItemType.AlternatingItem; } item = this.CreateItem(itemIndex, dataSourceIndex, editItem, useDataSource, current, array, rows, null); this.itemsArray.Add(item); dataItemCount++; dataSourceIndex++; itemIndex++; } this.CreateItem(-1, -1, ListItemType.Footer, useDataSource, null, array, rows, null); if (isPagingEnabled) { this.CreateItem(-1, -1, ListItemType.Pager, false, null, array, rows, this.pagedDataSource); } } if (useDataSource) { if (storedData != null) { this.ViewState["_!ItemCount"] = dataItemCount; if (this.pagedDataSource.IsPagingEnabled) { this.ViewState["PageCount"] = this.pagedDataSource.PageCount; this.ViewState["_!DataSourceItemCount"] = this.pagedDataSource.DataSourceCount; } else { this.ViewState["PageCount"] = 1; this.ViewState["_!DataSourceItemCount"] = dataItemCount; } } else { this.ViewState["_!ItemCount"] = -1; this.ViewState["_!DataSourceItemCount"] = -1; this.ViewState["PageCount"] = 0; } } this.pagedDataSource = null; }
protected virtual ArrayList CreateColumnSet(PagedDataSource dataSource, bool useDataSource) { int num; ArrayList list = new ArrayList(); DataGridColumn[] array = new DataGridColumn[this.Columns.Count]; this.Columns.CopyTo(array, 0); for (num = 0; num < array.Length; num++) { list.Add(array[num]); } if (this.AutoGenerateColumns) { ArrayList autoGenColumnsArray = null; if (useDataSource) { autoGenColumnsArray = this.CreateAutoGeneratedColumns(dataSource); this.autoGenColumnsArray = autoGenColumnsArray; } else { autoGenColumnsArray = this.autoGenColumnsArray; } if (autoGenColumnsArray == null) { return list; } int count = autoGenColumnsArray.Count; for (num = 0; num < count; num++) { list.Add(autoGenColumnsArray[num]); } } return list; }
public void Remove(DataGridColumn column) { columns.Remove(column); }
public int IndexOf(DataGridColumn column) { return(columns.IndexOf(column)); }
public ColumnItem(DataGridColumn runtimeColumn, int image) : base(string.Empty, image) { this.runtimeColumn = runtimeColumn; this.headerText = this.GetDefaultHeaderText(); base.Text = this.GetNodeText(null); }
public int IndexOf (DataGridColumn column) { Contract.Ensures (Contract.Result<int>() >= -1); return default(int); }
private void PrepareControlHierarchyForItem (DataGridColumn [] cols, DataGridItem item, int index, Style deployStyle) { switch (item.ItemType) { case ListItemType.Header: if (!ShowHeader) { item.Visible = false; break; } if (headerStyle != null) item.MergeStyle (headerStyle); goto case ListItemType.Separator; case ListItemType.Footer: if (!ShowFooter) { item.Visible = false; break; } if (footerStyle != null) item.MergeStyle (footerStyle); goto case ListItemType.Separator; case ListItemType.Item : item.MergeStyle (itemStyle); goto case ListItemType.Separator; case ListItemType.AlternatingItem: item.MergeStyle (deployStyle); goto case ListItemType.Separator; case ListItemType.SelectedItem: Style selStyle = new TableItemStyle (); if ((item.ItemIndex % 2) == 0) { selStyle.CopyFrom (itemStyle); } else { selStyle.CopyFrom (deployStyle); } selStyle.CopyFrom (selectedItemStyle); item.MergeStyle (selStyle); goto case ListItemType.Separator; case ListItemType.EditItem: Style edStyle = new TableItemStyle (); if ((item.ItemIndex % 2) == 0) { edStyle.CopyFrom (itemStyle); } else { edStyle.CopyFrom (deployStyle); } edStyle.CopyFrom (editItemStyle); item.MergeStyle (edStyle); goto case ListItemType.Separator; case ListItemType.Pager: if (pagerStyle == null) break; if (!pagerStyle.Visible) item.Visible = false; if (index == 0) { if (!pagerStyle.IsPagerOnTop) { item.Visible = false; break; } } else if (!pagerStyle.IsPagerOnBottom) { item.Visible = false; break; } item.MergeStyle (pagerStyle); goto case ListItemType.Separator; case ListItemType.Separator: TableCellCollection cells = item.Cells; int cellCount = cells.Count; if (cellCount > cols.Length) cellCount = cols.Length; if (cellCount > 0 && item.ItemType != ListItemType.Pager) { for (int i = 0; i < cellCount; i++) { Style colStyle = null; if (cols [i].Visible) { switch (item.ItemType) { case ListItemType.Header: colStyle = cols [i].HeaderStyleInternal; break; case ListItemType.Footer: colStyle = cols [i].FooterStyleInternal; break; default: colStyle = cols [i].ItemStyleInternal; break; } cells[i].MergeStyle (colStyle); } else { cells [i].Visible = false; } } } break; default: goto case ListItemType.Separator; } }
protected override void PrepareControlHierarchy() { if (Controls.Count == 0) return; Table display = (Table) Controls [0]; display.CopyBaseAttributes (this); if (ControlStyleCreated) { display.ApplyStyle (ControlStyle); } else { display.GridLines = GridLines.Both; display.CellSpacing = 0; } TableRowCollection rows = display.Rows; if (rows.Count == 0) return; int nCols = Columns.Count; DataGridColumn [] cols = new DataGridColumn [nCols]; Style deployStyle = null; if (nCols > 0) Columns.CopyTo (cols, 0); if (alternatingItemStyle != null) { deployStyle = new TableItemStyle (); deployStyle.CopyFrom (itemStyle); deployStyle.CopyFrom (alternatingItemStyle); } else { deployStyle = itemStyle; } int nrows = rows.Count; for (int counter = 0; counter < nrows; counter++) PrepareControlHierarchyForItem (cols, (DataGridItem) rows [counter], counter, deployStyle); }
private void setStyle(DataGridColumn c, ListItemType tp) { }
public FormatColumn(DataGridColumn runtimeColumn) { this.runtimeColumn = runtimeColumn; }
private void DataGridTest(string TestName, DataGridColumn c) { DataGrid grid1 = new DataGrid(); this.GHTSubTestBegin(TestName); try { grid1.Columns.Add(c); grid1.DataSource = GHDataSources.DSDataTable(); grid1.ShowFooter = true; grid1.DataBind(); base.GHTActiveSubTest.Controls.Add(grid1); } catch (Exception exception2) { Exception exception1 = exception2; this.GHTSubTestUnexpectedExceptionCaught(exception1); grid1 = null; } this.GHTSubTestEnd(); }
private DataGridItem CreateItem(int itemIndex, int dataSourceIndex, ListItemType itemType, bool dataBind, object dataItem, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource pagedDataSource) { DataGridItem item = CreateItem(itemIndex, dataSourceIndex, itemType); DataGridItemEventArgs e = new DataGridItemEventArgs(item); if (itemType != ListItemType.Pager) { InitializeItem(item, columns); if (dataBind) { item.DataItem = dataItem; } OnItemCreated(e); rows.Add(item); if (dataBind) { item.DataBind(); OnItemDataBound(e); item.DataItem = null; } } else { InitializePager(item, columns.Length, pagedDataSource); OnItemCreated(e); rows.Add(item); } return item; }
public void Add(DataGridColumn column) { this.AddAt(-1, column); }
/// <internalonly/> /// <devdoc> /// </devdoc> protected internal override void PrepareControlHierarchy() { if (Controls.Count == 0) return; Table childTable = (Table)Controls[0]; childTable.CopyBaseAttributes(this); childTable.Caption = Caption; childTable.CaptionAlign = CaptionAlign; if (ControlStyleCreated) { childTable.ApplyStyle(ControlStyle); } else { // Since we didn't create a ControlStyle yet, the default // settings for the default style of the control need to be applied // to the child table control directly // childTable.GridLines = GridLines.Both; childTable.CellSpacing = 0; } TableRowCollection rows = childTable.Rows; int rowCount = rows.Count; if (rowCount == 0) return; int columnCount = Columns.Count; DataGridColumn[] definedColumns = new DataGridColumn[columnCount]; if (columnCount > 0) Columns.CopyTo(definedColumns, 0); // the composite alternating item style, so we need to do just one // merge style on the actual item Style altItemStyle = null; if (alternatingItemStyle != null) { altItemStyle = new TableItemStyle(); altItemStyle.CopyFrom(itemStyle); altItemStyle.CopyFrom(alternatingItemStyle); } else { altItemStyle = itemStyle; } int visibleColumns = 0; bool calculateColumns = true; for (int i = 0; i < rowCount; i++) { DataGridItem item = (DataGridItem)rows[i]; switch (item.ItemType) { case ListItemType.Header: if (ShowHeader == false) { item.Visible = false; continue; // with the next row } else { if (headerStyle != null) { item.MergeStyle(headerStyle); } } break; case ListItemType.Footer: if (ShowFooter == false) { item.Visible = false; continue; // with the next row } else { item.MergeStyle(footerStyle); } break; case ListItemType.Pager: if (pagerStyle.Visible == false) { item.Visible = false; continue; // with the next row } else { if (i == 0) { // top pager if (pagerStyle.IsPagerOnTop == false) { item.Visible = false; continue; } } else { // bottom pager if (pagerStyle.IsPagerOnBottom == false) { item.Visible = false; continue; } } item.MergeStyle(pagerStyle); } break; case ListItemType.Item: item.MergeStyle(itemStyle); break; case ListItemType.AlternatingItem: item.MergeStyle(altItemStyle); break; case ListItemType.SelectedItem: // When creating the control hierarchy we first check if the // item is in edit mode, so we know this item cannot be in edit // mode. The only special characteristic of this item is that // it is selected. { Style s = new TableItemStyle(); if (item.ItemIndex % 2 != 0) s.CopyFrom(altItemStyle); else s.CopyFrom(itemStyle); s.CopyFrom(selectedItemStyle); item.MergeStyle(s); } break; case ListItemType.EditItem: // When creating the control hierarchy, we first check if the // item is in edit mode. So an item may be selected too, and // so both editItemStyle (more specific) and selectedItemStyle // are applied. { Style s = new TableItemStyle(); if (item.ItemIndex % 2 != 0) s.CopyFrom(altItemStyle); else s.CopyFrom(itemStyle); if (item.ItemIndex == SelectedIndex) s.CopyFrom(selectedItemStyle); s.CopyFrom(editItemStyle); item.MergeStyle(s); } break; } TableCellCollection cells = item.Cells; int cellCount = cells.Count; if ((columnCount > 0) && (item.ItemType != ListItemType.Pager)) { int definedCells = cellCount; if (columnCount < cellCount) definedCells = columnCount; for (int j = 0; j < definedCells; j++) { if (definedColumns[j].Visible == false) { cells[j].Visible = false; } else { if (item.ItemType == ListItemType.Item && calculateColumns) { visibleColumns++; } Style cellStyle = null; switch (item.ItemType) { case ListItemType.Header: cellStyle = definedColumns[j].HeaderStyleInternal; break; case ListItemType.Footer: cellStyle = definedColumns[j].FooterStyleInternal; break; default: cellStyle = definedColumns[j].ItemStyleInternal; break; } cells[j].MergeStyle(cellStyle); } } if (item.ItemType == ListItemType.Item) { calculateColumns = false; } } } if (Items.Count > 0 && visibleColumns != Items[0].Cells.Count && AllowPaging) { for (int i = 0; i < rowCount; i++) { DataGridItem item = (DataGridItem)rows[i]; if (item.ItemType == ListItemType.Pager && item.Cells.Count > 0) { item.Cells[0].ColumnSpan = visibleColumns; } } } }
public void Add(DataGridColumn column) { }
public int IndexOf(DataGridColumn column) { return default(int); }
public int IndexOf(DataGridColumn column) { return(default(int)); }
private void setText(DataGridColumn c, ListItemType tp, string text) { switch (tp) { case ListItemType.Header: { c.HeaderText = text; return; } case ListItemType.Footer: { c.FooterText = text; return; } } }
private void DataGridTest(string TestName, DataGridColumn c) { DataGrid grid1 = new DataGrid(); this.GHTSubTestBegin(TestName); try { grid1.Columns.Add(c); grid1.DataSource = GHTTests.GHDataSources.DSDataTable(); grid1.ShowFooter = true; grid1.DataBind(); base.GHTActiveSubTest.Controls.Add(grid1); this.GHTSubTestAddResult(grid1.Columns[0].SortExpression); } catch (Exception exception2) { // ProjectData.SetProjectError(exception2); Exception exception1 = exception2; this.GHTSubTestUnexpectedExceptionCaught(exception1); grid1 = null; // ProjectData.ClearProjectError(); } this.GHTSubTestEnd(); }
private DataGridItem CreateItem(int itemIndex, int dsIndex, ListItemType type, bool bind, object item, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource dataSrc) { DataGridItem retVal; DataGridItemEventArgs args; retVal = CreateItem(itemIndex, dsIndex, type); args = new DataGridItemEventArgs(retVal); if(type != ListItemType.Pager) { InitializeItem(retVal, columns); if(bind) { retVal.DataItem = item; } OnItemCreated(args); rows.Add(retVal); if(bind) { retVal.DataBind(); OnItemDataBound(args); retVal.DataItem = null; } } else { InitializePager(retVal, columns.Length, dataSrc); OnItemCreated(args); rows.Add(retVal); } return retVal; }
public CustomColumnItem(DataGridColumn runtimeColumn) : base(runtimeColumn, 3) { }
protected virtual void InitializeItem(DataGridItem item, DataGridColumn[] columns) { TableCellCollection cells = item.Cells; TableCell cCell; for(int i = 0; i < columns.Length; i++) { cCell = new TableCell(); columns[i].InitializeCell(cCell, i, item.ItemType); cells.Add(cCell); } }