private void CreateTableColumnStyle(DataTable m_Table, Views.ExControlView i_View) { //Columns width WebbTable i_PrintTable = i_View.PrintingTable; if (i_PrintTable == null) { return; } DataGridColumnStyle m_ColStyle = null; this.dataGrid1.TableStyles.Clear(); DataGridTableStyle m_TableStyle = new DataGridTableStyle(); m_TableStyle.AllowSorting = false; m_TableStyle.MappingName = m_Table.TableName; int m_cols = i_PrintTable.GetColumns(); int m_rows = i_PrintTable.GetRows(); //System.Diagnostics.Debug.Assert(m_Table.Rows.Count == m_rows && m_Table.Columns.Count == m_cols); for (int m_col = 0; m_col < m_cols; m_col++) { m_ColStyle = new DataGridTextBoxColumn(); WebbTableCell cell = i_PrintTable.GetCell(0, m_col) as WebbTableCell; if (cell != null) //Modified at 2008-11-11 11:09:29@Scott { m_ColStyle.Width = i_PrintTable.GetCell(0, m_col).CellStyle.Width; m_ColStyle.MappingName = m_Table.Columns[m_col].ColumnName; m_ColStyle.HeaderText = string.Empty; m_TableStyle.GridColumnStyles.Add(m_ColStyle); } } this.dataGrid1.TableStyles.Add(m_TableStyle); }
public void SetHeadGridLine(WebbTable table, Webb.Collections.Int32Collection HeaderRowsArray) { int rows = table.GetRows(); int cols = table.GetColumns(); if (this.GridLine || HeaderRowsArray.Count <= 0 || cols <= 0 || rows <= 0) { return; } int maxH = (int)HeaderRowsArray[0], minH = (int)HeaderRowsArray[0]; foreach (int hrow in HeaderRowsArray) //Get the Max rowindex and min rowindex of HeaderRows { maxH = Math.Max(maxH, hrow); minH = Math.Min(minH, hrow); } for (int i = minH; i <= maxH; i++) { if (i >= rows) { return; } for (int j = 0; j < cols; j++) { IWebbTableCell bordercell = table.GetCell(i, j); bordercell.CellStyle.Sides = DevExpress.XtraPrinting.BorderSide.None; if (i == minH) { bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Top; } if (j == 0) { bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Left; } if (j == cols - 1) { bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Right; } if (i == maxH) { bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Bottom; } if (i == minH && this.ColsToMerge.Contains(j)) { bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Bottom;; } if (j < this.ColCount && i < maxH) { HeaderCell hc = GetCell(i, j); if (j + hc.MergerdCount - 1 == cols - 1) { bordercell.CellStyle.Sides |= DevExpress.XtraPrinting.BorderSide.Right; } ; } } } }
//public void SetHeaders(WebbTable table,ref int nRow) //{ // int cols=table.GetColumns(); // if(cols<=0)return; // for(int i=0;i<this.RowCount;i++) // { // for(int j=0;j<this._ColCount;j++) // { // if(i>=table.GetRows()||j>=cols)continue; // HeaderCell hc=GetCell(i,j); // IWebbTableCell tablecell=table.GetCell(i+nRow,j); // if(hc.MergerdCount>0) // { // int StartIndex=j; // int EndIndex=j+hc.MergerdCount-1; // if(EndIndex>=cols)EndIndex=cols-1; // if(EndIndex>StartIndex) // { // table.MergeCells(i,i,StartIndex,EndIndex); // } // if(hc.Text!="")tablecell.Text=hc.Text; // j=EndIndex; // } // else // { // if(hc.Text!="")tablecell.Text=hc.Text; // } // } // } // nRow+=this.RowCount; //} #endregion public void SetHeaders(WebbTable table, ref int nRow, Views.ExControlView i_View) { int totalColumnsInTable = table.GetColumns(); if (totalColumnsInTable <= 0) { return; } for (int i = 0; i < this.RowCount; i++) { for (int j = 0; j < this._ColCount; j++) { if (i >= table.GetRows() || j >= totalColumnsInTable) { continue; } HeaderCell hc = GetCell(i, j); IWebbTableCell tablecell = table.GetCell(i + nRow, j); if (hc == null || tablecell == null) { continue; } string strHeaderText = hc.Text; strHeaderText = strHeaderText.Replace("[onevalue]", i_View.OneValueScFilter.FilterName); strHeaderText = strHeaderText.Replace("[repeat]", i_View.RepeatFilter.FilterName); strHeaderText = strHeaderText.Replace("[ONEVALUE]", i_View.OneValueScFilter.FilterName); strHeaderText = strHeaderText.Replace("[REPEAT]", i_View.RepeatFilter.FilterName); if (hc.MergerdCount > 0) { int StartIndex = j; int EndIndex = j + hc.MergerdCount - 1; if (EndIndex >= totalColumnsInTable) { EndIndex = totalColumnsInTable - 1; } if (EndIndex > StartIndex) { table.MergeCells(i, i, StartIndex, EndIndex); } tablecell.Text = strHeaderText; j = EndIndex; } else { tablecell.MergeType = MergeTypes.None; tablecell.Text = strHeaderText; } } } nRow += this.RowCount; }
private int GetMatrixMergedCount(WebbTable table) { if (MatrixInfo != null) { if (!MatrixInfo.ShowInOneCol) { if (MatrixInfo.CellTotal.ShowTotal) { return(2); } else { return(1); } } } int count = 1; //RowGroup Result int index = 0; if (this.ShowRowIndicators) { index = 1; } int MaxRows = table.GetRows(); if (index >= table.GetColumns() || table.HeaderCount >= MaxRows) { return(1); } int row = table.HeaderCount; IWebbTableCell cell = table.GetCell(row, index); while ((cell.MergeType & MergeTypes.Down) != MergeTypes.Down) { row++; if (row >= MaxRows) { break; } cell = table.GetCell(row, index); } if (row >= MaxRows - 1) { return(1); } row++; cell = table.GetCell(row, index); while ((cell.MergeType & MergeTypes.Merged) == MergeTypes.Merged) { count++; row++; if (row >= MaxRows || (cell.MergeType & MergeTypes.End) == MergeTypes.End) { break; } cell = table.GetCell(row, index); } return(count); }