Pen DgGridPen(SectionTable table, System.Windows.Forms.DataGridTableStyle tableStyle) { Pen pen = null; if (tableStyle.GridLineStyle == System.Windows.Forms.DataGridLineStyle.Solid) { pen = new Pen (tableStyle.GridLineColor, CurrentDocument.ThinPen.Width); table.OuterPens = pen; table.InnerPenHeaderBottom = pen; table.InnerPenRow = pen; } return pen; }
void DgApplyTableStyles(SectionTable table, System.Windows.Forms.DataGridTableStyle tableStyle) { // use tableStyle properties table.HeaderTextStyle.SetFromFont (tableStyle.HeaderFont); table.HeaderTextStyle.Brush = new SolidBrush (tableStyle.HeaderForeColor); table.HeaderTextStyle.BackgroundBrush = new SolidBrush (tableStyle.HeaderBackColor); table.DetailRowTextStyle.Brush = new SolidBrush (tableStyle.ForeColor); table.DetailRowTextStyle.BackgroundBrush = new SolidBrush (tableStyle.BackColor); table.AlternatingRowTextStyle.BackgroundBrush = new SolidBrush (tableStyle.AlternatingBackColor); }
void DgApplyTableStyles(SectionTable table, System.Windows.Forms.DataGrid dataGrid) { // use grid defaults table.HeaderTextStyle.SetFromFont (dataGrid.HeaderFont); table.HeaderTextStyle.Brush = new SolidBrush (dataGrid.HeaderForeColor); table.HeaderTextStyle.BackgroundBrush = new SolidBrush (dataGrid.HeaderBackColor); table.DetailRowTextStyle.Brush = new SolidBrush (dataGrid.ForeColor); table.DetailRowTextStyle.BackgroundBrush = new SolidBrush (dataGrid.BackColor); table.AlternatingRowTextStyle.BackgroundBrush = new SolidBrush (dataGrid.AlternatingBackColor); }
void DgApplyDefaultStyles(SectionTable table, float textSize) { table.HeaderTextStyle.Size = textSize; table.DetailRowTextStyle.Size = textSize; // add space around columns... table.HeaderTextStyle.MarginFar = 0.05f * CurrentDocument.GetScale(); table.HeaderTextStyle.MarginNear = 0.05f * CurrentDocument.GetScale(); table.DetailRowTextStyle.MarginFar = 0.05f * CurrentDocument.GetScale(); table.DetailRowTextStyle.MarginNear = 0.05f * CurrentDocument.GetScale(); }
void DgAddColumns(SectionTable table, System.Windows.Forms.DataGridTableStyle tableStyle) { foreach (System.Windows.Forms.DataGridColumnStyle columnStyle in tableStyle.GridColumnStyles) { float width = columnStyle.Width / DataGridToPrinterHScale * CurrentDocument.GetScale(); ReportDataColumn col = AddColumn(columnStyle.MappingName, columnStyle.HeaderText, width, true, true, (ReportPrinting.HorizontalAlignment)columnStyle.Alignment); col.NullValueString = columnStyle.NullText; System.Windows.Forms.DataGridTextBoxColumn dgtbc = columnStyle as System.Windows.Forms.DataGridTextBoxColumn; if (dgtbc != null) { col.FormatExpression = dgtbc.Format; } } }
/// <summary> /// Adds a data section with no default columns. /// Use the AddColumn() method to add those. /// </summary> /// <param name="dataSource">DataView for the source of data</param> /// <param name="repeatHeaderRow">Indicates a header row should be printed at the top of every page, /// instead of just the first. Use Table.SuppressHeaderRow to turn off all headers</param> /// <param name="tablePercentWidth">The width of the table as a percentage of the parent.</param> /// <returns>ReportSection just created</returns> /// <remarks> /// <para> /// If a non-zero tablePercentWidth is specified, then columns will be /// widened or narrowed proportionately, based on the desired width of /// each column. The maxColumnWidth is no longer guaranteed to be the max column width. /// Here is the algorithm: /// </para> /// <list type="number"> /// <item><description>Set each column width to maxColumnWidth</description></item> /// <item><description>If sizeWidthToHeader and/or sizeWidthToContents are set, then /// reduce each column's width down to that necessary for the header and/or contents.</description></item> /// <item><description>Finally, take the combined widths of all columns and stretch them to /// make the table have the tablePercentWidth.</description></item> /// </list> /// </remarks> public SectionTable AddTable( DataView dataSource, bool repeatHeaderRow, float tablePercentWidth ) { SectionTable section = new SectionTable(dataSource); section.RepeatHeaderRow = repeatHeaderRow; section.MaxDetailRowHeight = this.MaxDetailRowHeight; section.MinDetailRowHeight = this.MinDetailRowHeight; section.MaxHeaderRowHeight = this.MaxHeaderRowHeight; section.MinHeaderRowHeight = this.MinHeaderRowHeight; section.InnerPenHeaderBottom = this.DefaultTablePen; section.InnerPenRow = this.DefaultTablePen; section.OuterPens = this.DefaultTablePen; section.PercentWidth = tablePercentWidth; AddSection(section); return section; }