/// <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="rowIndex"></param> /// <param name="dataItemIndex"></param> /// <param name="rowType"></param> /// <param name="rowState"></param> public DataGridViewRow(int rowIndex, int dataItemIndex, DataGridViewRowType rowType, DataGridViewRowState rowState) { this.rowIndex = rowIndex; this.dataItemIndex = dataItemIndex; this.rowType = rowType; this.rowState = rowState; }
DataGridViewRow CreateRow(int rowIndex, int dataSourceIndex, DataGridViewRowType rowType, DataGridViewRowState rowState, bool dataBind, object dataItem, DataControlFieldEx[] fields, TableRowCollection rows, PagedDataSourceEx pagedDataSource) { DataGridViewRow row = this.CreateRow(rowIndex, dataSourceIndex, rowType, rowState); DataGridViewRowEventArgs e = new DataGridViewRowEventArgs(row); if (rowType != DataGridViewRowType.Footer) this.InitializeRow(row, fields); else this.InitializePager(row, fields.Length, pagedDataSource); if (dataBind) row.DataItem = dataItem; this.OnRowCreated(e); rows.Add(row); if (dataBind) { row.DataBind(); this.OnRowDataBound(e); row.DataItem = null; } return row; }