コード例 #1
0
        public virtual ReportColumnCollection GetColumns()
        {
            ReportColumnCollection toRet = new ReportColumnCollection();

            foreach (DataColumn dataColumn in dataView.Table.Columns)
            {
                ReportDataColumn rdColumn = toRet.AddNewReportDataColumn(dataColumn.ColumnName);

                rdColumn.HeaderText = dataColumn.Caption;
                rdColumn.ValueType  = dataColumn.DataType;

                if (rdColumn.ValueType == typeof(System.Drawing.Image))
                {
                    rdColumn.DataCellViewType = CellViewImage.CreateDatabaseImage(ImageMIMEType.Jpeg);
                }
                else if (rdColumn.ValueType == typeof(System.Drawing.Bitmap))
                {
                    rdColumn.DataCellViewType = CellViewImage.CreateDatabaseImage(ImageMIMEType.Bmp);
                }

                rdColumn.HeaderStyle.Border          =
                    rdColumn.DefaultCellStyle.Border = DefaultBorder;

                rdColumn.DefaultCellStyle.Width = new Size(DefaultColumnWidth);
                rdColumn.DefaultCellStyle.Wrap  = true;
            }

            return(toRet);
        }
コード例 #2
0
        public virtual ReportColumnCollection GetColumns()
        {
            ReportColumnCollection toRet = new ReportColumnCollection();

            foreach (DataGridViewColumn dgvColumn in dataGridView.Columns)
            {
                ReportDataColumn rdColumn = toRet.AddNewReportDataColumn(dgvColumn.Name);

                rdColumn.HeaderText = dgvColumn.HeaderText;
                rdColumn.ValueType  = dgvColumn.ValueType;

                if (dgvColumn is DataGridViewImageColumn)
                {
                    CellViewImage databaseCellViewImage = CellViewImage.CreateDatabaseImage(ImageMIMEType.Jpeg);
                    //databaseCellViewImage.Sizing = ImageSizing.FitProportional;
                    rdColumn.DataCellViewType = databaseCellViewImage;
                }

                {                 //initialize style for column header cell
                    InitReportStyleFrom(
                        rdColumn.HeaderStyle,
                        dgvColumn.HeaderCell.HasStyle ? dgvColumn.HeaderCell.Style : dgvColumn.HeaderCell.InheritedStyle);
                }

                {                 //initialize style for column content cell
                    InitReportStyleFrom(rdColumn.DefaultCellStyle,
                                        dgvColumn.HasDefaultCellStyle ? dgvColumn.DefaultCellStyle : dgvColumn.InheritedStyle);
                }

                //set column width
                rdColumn.HeaderStyle.Width          =
                    rdColumn.DefaultCellStyle.Width =
                        new System.Web.UI.WebControls.Unit(dgvColumn.Width, System.Web.UI.WebControls.UnitType.Pixel);
            }

            return(toRet);
        }