/// <summary> /// 初始化在分页功能启用时显示的页导航行。 /// </summary> /// <param name="row">表示要初始化的页导航行。</param> /// <param name="columnSpan">页导航行应跨越的列数。</param> /// <param name="pagedDataSource">数据源。</param> protected virtual void InitializePager(DataGridViewRow row, int columnSpan, PagedDataSourceEx pagedDataSource) { TableCell cell = new TableCell(); if (columnSpan > 1) cell.ColumnSpan = columnSpan; PagerSettingsEx pagerSettings = this.PagerSettings; Panel panel = new Panel(); panel.CssClass = this.PagingDataCss; Table child = new Table(); child.CellPadding = 0; child.CellSpacing = 0; child.BorderWidth = 0; TableRow tr = new TableRow(); tr.HorizontalAlign = HorizontalAlign.Left; switch (pagerSettings.Mode) { case PagerButtons.NextPrevious: this.CreateNextPrevPager(tr, pagedDataSource, false); break; case PagerButtons.Numeric: this.CreateNumericPager(tr, pagedDataSource, false); break; case PagerButtons.NextPreviousFirstLast: // this.CreateNextPrevPager(tr, pagedDataSource, true); this.CreateDefaultNextPreviousFirstLastPager(tr, pagedDataSource); break; case PagerButtons.NumericFirstLast: this.CreateNumericPager(tr, pagedDataSource, true); break; } child.Rows.Add(tr); panel.Controls.Add(child); cell.Controls.Add(panel); //导出 this.CreateExportControl(cell); row.Cells.Add(cell); }
/// <summary> /// 检索在指定行中声明的每个字段的值,并将它们存储在指定的 <see cref="IOrderedDictionary"/> 对象中。 /// </summary> /// <param name="fieldValues">用来存储字段值的<see cref="IOrderedDictionary"/> 。</param> /// <param name="row">将从其中检索字段值的<see cref="DataGridViewRow"/>。</param> /// <param name="includeReadOnlyFields">true 表示包含只读字段;否则为 false。</param> /// <param name="includePrimaryKey">true 表示包含主键字段;否则为 false。</param> protected virtual void ExtractRowValues(IOrderedDictionary fieldValues, DataGridViewRow row, bool includeReadOnlyFields, bool includePrimaryKey) { if (fieldValues != null) { ICollection collection = this.CreateColumns(null, false); int count = collection.Count; object[] array = new object[count]; collection.CopyTo(array, 0); for (int i = 0; (i < count) && (i < row.Cells.Count); i++) { if (((DataControlFieldEx)array[i]).Visible) { OrderedDictionary dictionary = new OrderedDictionary(); ((DataControlFieldEx)array[i]).ExtractValuesFromCell(dictionary, row.Cells[i] as DataControlFieldCellEx, row.RowState, includeReadOnlyFields); foreach (DictionaryEntry entry in dictionary) { // if (includePrimaryKey) fieldValues[entry.Key] = entry.Value; } } } } }
/// <summary> /// 初始化行。 /// </summary> /// <param name="row"></param> /// <param name="fields"></param> protected virtual void InitializeRow(DataGridViewRow row, DataControlFieldEx[] fields) { DataGridViewRowType rowType = row.RowType; DataGridViewRowState rowState = row.RowState; int rowIndex = row.RowIndex; TableCellCollection cells = row.Cells; string rowHeaderColumn = this.RowHeaderColumn; bool useAccessibleHeader = false; if (rowType == DataGridViewRowType.Header) useAccessibleHeader = this.UseAccessibleHeader; for (int i = 0; i < fields.Length; i++) { DataControlFieldCellEx cell = null; DataControlCellType header = DataControlCellType.DataCell; if ((rowType == DataGridViewRowType.Header) && useAccessibleHeader) { cell = new DataControlFieldHeaderCellEx(fields[i]); ((DataControlFieldHeaderCellEx)cell).Scope = TableHeaderScope.Column; ((DataControlFieldHeaderCellEx)cell).AbbreviatedText = fields[i].AccessibleHeaderText; } else { BoundFieldEx field = fields[i] as BoundFieldEx; if (!string.IsNullOrEmpty(rowHeaderColumn) && (field != null) && (field.DataField == rowHeaderColumn)) { cell = new DataControlFieldHeaderCellEx(fields[i]); ((DataControlFieldHeaderCellEx)cell).Scope = TableHeaderScope.Row; } else cell = new DataControlFieldCellEx(fields[i]); } switch (rowType) { case DataGridViewRowType.Header: header = DataControlCellType.Header; break; case DataGridViewRowType.Footer: header = DataControlCellType.Footer; break; default: header = DataControlCellType.DataCell; break; } fields[i].InitializeCell(cell,header, rowState, rowIndex); cells.Add(cell); } }
/// <summary> /// 创建行。 /// </summary> /// <param name="rowIndex">要创建的行的索引。</param> /// <param name="dataSourceIndex">要绑定到行的数据源项的索引。</param> /// <param name="rowType">行类型。</param> /// <param name="rowState">行状态。</param> /// <returns></returns> protected virtual DataGridViewRow CreateRow(int rowIndex, int dataSourceIndex, DataGridViewRowType rowType, DataGridViewRowState rowState) { DataGridViewRow row = new DataGridViewRow(rowIndex, dataSourceIndex, rowType, rowState); if (rowType == DataGridViewRowType.DataRow) { row.Attributes.Add("onmouseout", string.Format("this.className='{0}';", rowState == DataGridViewRowState.AlterNate ? this.AlternatingRowStyle.CssClass : this.RowStyle.CssClass)); row.Attributes.Add("onmouseover", string.Format("this.className='{0}';", this.MouseoverCssClass)); } return row; }
/// <summary> /// 构造函数。 /// </summary> /// <param name="row"></param> public DataGridViewRowEventArgs(DataGridViewRow row) { this.row = row; }
/// <summary> /// /// </summary> /// <param name="array"></param> /// <param name="index"></param> public void CopyTo(DataGridViewRow[] array, int index) { ((ICollection)this).CopyTo(array, index); }
/// <summary> /// ���������塣 /// </summary> /// <param name="row">�����С�</param> /// <param name="columns">�������ϡ�</param> /// <param name="split">�ָ����</param> /// <returns>�����ַ�����</returns> protected string ExportItem(DataGridViewRow row, DataControlFieldExCollection columns, string split) { StringBuilder strRowData = new StringBuilder(); if (row != null && columns != null) { DataGridViewRowState rowState = row.RowState; if ((rowState == DataGridViewRowState.Normal) || (rowState == DataGridViewRowState.AlterNate)) { int index = 0; string strValue = string.Empty; foreach (DataControlFieldEx ctrlField in columns) { if (ctrlField.Visible) { if (ctrlField is MultiQueryStringFieldEx) { string result = string.Empty; if (row.Cells[index].Controls[0] is HtmlAnchor) result = ((HtmlAnchor)row.Cells[index].Controls[0]).InnerText; strValue = result.Replace("\r\n", string.Empty).Replace(',', '��'); strValue = this.CellDataFormat(strValue); strRowData.AppendFormat("{0}{1}", split, strValue); } else if (!(ctrlField is CheckBoxFieldEx)) { strValue = row.Cells[index].Text.Replace("\r\n", string.Empty).Replace(',', '��'); strValue = this.CellDataFormat(strValue); strRowData.AppendFormat("{0}{1}", split, strValue); } } index++; } } } if (strRowData.Length > 0) strRowData.Remove(0, 1); return strRowData.ToString(); }
/// <summary> /// 构造函数。 /// </summary> /// <param name="row"></param> /// <param name="commandSource"></param> /// <param name="args"></param> public DataGridViewCommandEventArgs(DataGridViewRow row, object commandSource, CommandEventArgs args) : base(args) { this.row = row; this.commandSource = commandSource; }