public void CreateSizeGrid(DevExpress.XtraGrid.GridControl gridControl, BandedGridView gridView, DataTable dt) { //gridControl.Hide(); gridView.BeginDataUpdate(); try { bool flag = false; gridView.OptionsView.ShowGroupPanel = false; gridView.OptionsView.AllowCellMerge = true; gridView.Columns.Clear(); gridView.Bands.Clear(); gridView.OptionsView.ShowColumnHeaders = false; gridView.OptionsView.ColumnAutoWidth = false; DevExpress.XtraGrid.Views.BandedGrid.GridBand[] band_parent = new DevExpress.XtraGrid.Views.BandedGrid.GridBand[dt.Columns.Count]; DevExpress.XtraGrid.Views.BandedGrid.GridBand[] band_child = new DevExpress.XtraGrid.Views.BandedGrid.GridBand[dt.Columns.Count - 2]; int i_arr = 0; for (int i = 0; i < dt.Columns.Count; i++) { //if (i<=1) //{ band_parent[i] = new GridBand() { Caption = dt.Columns[i].ColumnName.ToString() }; gridView.Bands.Add(band_parent[i]); band_parent[i].Columns.Add(new BandedGridColumn() { FieldName = dt.Columns[i].ColumnName.ToString(), Visible = true, Caption = band_parent[i].Caption }); //} // else ////{ // if (!flag) // { // band_parent[i] = new GridBand() { Caption = "COMPONENT INCOMING" }; // gridView.Bands.Add(band_parent[i]); // band_parent[i].Children.Add(new GridBand() { Caption = dt.Columns[i].ColumnName.ToString() }); // band_parent[i].Children[i_arr].Columns.Add(new BandedGridColumn() { FieldName = dt.Columns[i].ColumnName.ToString(), Visible = true, Caption = dt.Columns[i].ColumnName.ToString() }); // i_arr++; // band_parent[i].Children[0].RowCount = 2; // flag = true; // } // else // { // band_parent[band_parent.Count() - 1].Children.Add(new GridBand() { Caption = dt.Columns[i].ColumnName.ToString() }); // band_parent[band_parent.Count() - 1].Children[i_arr].Columns.Add(new BandedGridColumn() { FieldName = dt.Columns[i].ColumnName.ToString(), Visible = true, Caption = dt.Columns[i].ColumnName.ToString() }); // i_arr++; // } ////} } band_parent[0].RowCount = 2; gridView.OptionsView.ColumnAutoWidth = false; } catch (Exception EX) { //throw EX; } gridView.EndDataUpdate(); gridView.ExpandAllGroups(); }
private void CreateBands(out DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand1, out DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand2) { gridBand1 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand(); gridBand2 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand(); gridBand1.Name = "BandsHeader"; gridBand1.Caption = "FABRIC COST DATA"; gridBand1.AppearanceHeader.Font = new Font(gridBand1.AppearanceHeader.Font.Name, 40); gridBand1.RowCount = 1; gridBand2.Name = "BandsEstCost"; gridBand2.Caption = "ESTIMATE COST"; gridBand1.RowCount = 1; bgvFabric.Bands.Add(gridBand1); bgvFabric.Bands.Add(gridBand2); bgvFabric.Bands[0].AppearanceHeader.Font = new Font(gridBand1.AppearanceHeader.Font.Name, 10, FontStyle.Bold); bgvFabric.Bands[0].AppearanceHeader.BackColor = Color.FromArgb(64, 0, 0); bgvFabric.Bands[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bgvFabric.Bands[1].AppearanceHeader.Font = new Font(gridBand1.AppearanceHeader.Font.Name, 9); bgvFabric.Bands[1].AppearanceHeader.BackColor = Color.DarkRed; bgvFabric.Bands[1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; }
/// <summary> /// 밴드에 컬럼을 추가합니다. /// </summary> /// <param name="Band">The band.</param> /// <param name="Caption">The caption.</param> /// <param name="FieldName">Name of the field.</param> /// <param name="Name">The name.</param> /// <param name="Allgment">The allgment.</param> /// <param name="Width">The width.</param> private void SetAddBandColumn(DevExpress.XtraGrid.Views.BandedGrid.GridBand Band, string Caption, string FieldName, string Name, DevExpress.Utils.HorzAlignment Allgment, int Width) { try { DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandColumn = new BandedGridColumn(); bandColumn.AppearanceHeader.Options.UseTextOptions = true; bandColumn.AppearanceHeader.TextOptions.HAlignment = Allgment; bandColumn.Caption = Caption; bandColumn.FieldName = FieldName; bandColumn.Name = Name; bandColumn.Width = Width; Band.Columns.Add(bandColumn); } catch (Exception ex) { throw ex; } }
private void InitializeComponent() { this.gridBand1 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand(); this.gridControl1 = new DevExpress.XtraGrid.GridControl(); this.advBandedGridView1 = new DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView(); ((System.ComponentModel.ISupportInitialize)this.gridControl1).BeginInit(); ((System.ComponentModel.ISupportInitialize)this.advBandedGridView1).BeginInit(); this.SuspendLayout(); // //gridBand1 // this.gridBand1.Caption = "gridBand1"; this.gridBand1.Name = "gridBand1"; // //gridControl1 // this.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.gridControl1.Location = new System.Drawing.Point(0, 0); this.gridControl1.MainView = this.advBandedGridView1; this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(821, 513); this.gridControl1.TabIndex = 7; this.gridControl1.UseEmbeddedNavigator = true; this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {this.advBandedGridView1}); // //advBandedGridView1 // this.advBandedGridView1.Bands.AddRange(new DevExpress.XtraGrid.Views.BandedGrid.GridBand[] {this.gridBand1}); this.advBandedGridView1.GridControl = this.gridControl1; this.advBandedGridView1.Name = "advBandedGridView1"; // //Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(821, 513); this.Controls.Add(this.gridControl1); this.Name = "Form1"; this.Text = "How to hide the grid columns displayed in the bands when grouping is applied"; ((System.ComponentModel.ISupportInitialize)this.gridControl1).EndInit(); ((System.ComponentModel.ISupportInitialize)this.advBandedGridView1).EndInit(); this.ResumeLayout(false); advBandedGridView1.EndGrouping += new System.EventHandler(advBandedGridView1_EndGrouping); base.Load += new System.EventHandler(Form1_Load); }
private void formatband() { try { int n; DataTable dtsource = null; dtsource = db.SEL_OS_OSD_EXT("H", ""); if (dtsource != null && dtsource.Rows.Count > 0) { string name; //bandMon.Caption = dtsource.Rows[0]["MON"].ToString(); if (dtsource.Rows.Count > 0) { gvwView.Bands.Clear(); gvwView.Columns.Clear(); DevExpress.XtraGrid.Views.BandedGrid.GridBand bMonth = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = "Month" }; DevExpress.XtraGrid.Views.BandedGrid.GridBand bDate = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = "Date" }; DevExpress.XtraGrid.Views.BandedGrid.GridBand bMon1 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[0]["DATE_1"].ToString() }; DevExpress.XtraGrid.Views.BandedGrid.GridBand bAVG = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = "AVG" }; DevExpress.XtraGrid.Views.BandedGrid.GridBand bTotal = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = "Total" }; if (dtsource.Rows[0]["CNT"].ToString() == "1") { gvwView.Bands.Add(bMonth); gvwView.Bands.Add(bMon1); gvwView.Bands.Add(bAVG); gvwView.Bands.Add(bTotal); bMonth.Children.Add(bDate); bDate.Columns.Add(new BandedGridColumn() { FieldName = "LINE_CD", Visible = true, Caption = "Date" }); bAVG.Columns.Add(new BandedGridColumn() { FieldName = "COLAVG", Visible = true, Caption = "AVG" }); bTotal.Columns.Add(new BandedGridColumn() { FieldName = "COLTOTAL", Visible = true, Caption = "Total" }); for (int i = 0; i < dtsource.Rows.Count; i++) { DevExpress.XtraGrid.Views.BandedGrid.GridBand bchild = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[i]["DD"].ToString() }; if (dtsource.Rows[i]["VAL_RANK"].ToString() == "1") { bMon1.Children.Add(bchild); bchild.Columns.Add(new BandedGridColumn() { FieldName = dtsource.Rows[i]["COL"].ToString(), Visible = true, Caption = dtsource.Rows[i]["DD"].ToString() }); } } int i_width = 0; i_width = (grdView.Width - 160) / dtsource.Rows.Count; bMon1.Width = i_width * bMon1.Children.Count; bMonth.Width = 65; bAVG.Width = 50; bAVG.AppearanceHeader.BackColor = Color.Orange; bTotal.Width = 50; bTotal.AppearanceHeader.BackColor = Color.DodgerBlue; gvwView.OptionsView.ColumnAutoWidth = false; } else if (dtsource.Rows[0]["CNT"].ToString() == "2") { DevExpress.XtraGrid.Views.BandedGrid.GridBand bMon2 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[0]["DATE_2"].ToString() }; gvwView.Bands.Add(bMonth); gvwView.Bands.Add(bMon1); gvwView.Bands.Add(bMon2); gvwView.Bands.Add(bAVG); gvwView.Bands.Add(bTotal); bMonth.Children.Add(bDate); bDate.Columns.Add(new BandedGridColumn() { FieldName = "LINE_CD", Visible = true, Caption = "Date" }); bAVG.Columns.Add(new BandedGridColumn() { FieldName = "COLAVG", Visible = true, Caption = "AVG" }); bTotal.Columns.Add(new BandedGridColumn() { FieldName = "COLTOTAL", Visible = true, Caption = "Total" }); for (int i = 0; i < dtsource.Rows.Count; i++) { DevExpress.XtraGrid.Views.BandedGrid.GridBand bchild = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[i]["DD"].ToString() }; if (dtsource.Rows[i]["VAL_RANK"].ToString() == "1") { bMon1.Children.Add(bchild); bchild.Columns.Add(new BandedGridColumn() { FieldName = dtsource.Rows[i]["COL"].ToString(), Visible = true, Caption = dtsource.Rows[i]["DD"].ToString() }); } else if (dtsource.Rows[i]["VAL_RANK"].ToString() == "2") { bMon2.Children.Add(bchild); bchild.Columns.Add(new BandedGridColumn() { FieldName = dtsource.Rows[i]["COL"].ToString(), Visible = true, Caption = dtsource.Rows[i]["DD"].ToString() }); } } int i_width = 0; i_width = (grdView.Width - 160) / dtsource.Rows.Count; bMon1.Width = i_width * bMon1.Children.Count; bMon2.Width = i_width * bMon2.Children.Count; bMonth.Width = 65; bAVG.Width = 50; bAVG.AppearanceHeader.BackColor = Color.Orange; bTotal.Width = 50; bTotal.AppearanceHeader.BackColor = Color.DodgerBlue; gvwView.OptionsView.ColumnAutoWidth = false; } else { DevExpress.XtraGrid.Views.BandedGrid.GridBand bMon2 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[0]["DATE_2"].ToString() }; DevExpress.XtraGrid.Views.BandedGrid.GridBand bMon3 = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[0]["DATE_3"].ToString() }; gvwView.Bands.Add(bMonth); gvwView.Bands.Add(bMon1); gvwView.Bands.Add(bMon2); gvwView.Bands.Add(bMon3); gvwView.Bands.Add(bAVG); gvwView.Bands.Add(bTotal); bMonth.Children.Add(bDate); bDate.Columns.Add(new BandedGridColumn() { FieldName = "LINE_CD", Visible = true, Caption = "Date" }); bAVG.Columns.Add(new BandedGridColumn() { FieldName = "COLAVG", Visible = true, Caption = "AVG" }); bTotal.Columns.Add(new BandedGridColumn() { FieldName = "COLTOTAL", Visible = true, Caption = "Total" }); for (int i = 0; i < dtsource.Rows.Count; i++) { DevExpress.XtraGrid.Views.BandedGrid.GridBand bchild = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Caption = dtsource.Rows[i]["DD"].ToString() }; if (dtsource.Rows[i]["VAL_RANK"].ToString() == "1") { bMon1.Children.Add(bchild); bchild.Columns.Add(new BandedGridColumn() { FieldName = dtsource.Rows[i]["COL"].ToString(), Visible = true, Caption = dtsource.Rows[i]["DD"].ToString() }); } else if (dtsource.Rows[i]["VAL_RANK"].ToString() == "2") { bMon2.Children.Add(bchild); bchild.Columns.Add(new BandedGridColumn() { FieldName = dtsource.Rows[i]["COL"].ToString(), Visible = true, Caption = dtsource.Rows[i]["DD"].ToString() }); } else { bMon3.Children.Add(bchild); bchild.Columns.Add(new BandedGridColumn() { FieldName = dtsource.Rows[i]["COL"].ToString(), Visible = true, Caption = dtsource.Rows[i]["DD"].ToString() }); } } int i_width = 0; i_width = (grdView.Width - 160) / dtsource.Rows.Count; bMon1.Width = i_width * bMon1.Children.Count; bMon2.Width = i_width * bMon2.Children.Count; bMon3.Width = i_width * bMon3.Children.Count; bMonth.Width = 65; bAVG.Width = 50; bAVG.AppearanceHeader.BackColor = Color.Orange; bTotal.Width = 50; bTotal.AppearanceHeader.BackColor = Color.DodgerBlue; gvwView.OptionsView.ColumnAutoWidth = false; } } } } catch (Exception ex) { return; } }
private void btnGetReport_Click(object sender, EventArgs e) { if (!base.ProcessValidationFormControls()) { return; } int?DepartmentID = ucEmployeeFilter1.DepartmentID; if (DepartmentID == -1) { DepartmentID = null; } int?DesignationID = ucEmployeeFilter1.DesignationID; if (DesignationID == -1) { DesignationID = null; } int?LocationID = ucEmployeeFilter1.LocationID; if (LocationID == -1) { LocationID = null; } int?EmployementTypeID = ucEmployeeFilter1.EmploymentType - 1; if (EmployementTypeID == -1) { EmployementTypeID = null; } var ds = (new DAL.Payroll.EmployeeAttendanceDAL()).GetEmployeeAttendanceData(ucEmployeeFilter1.DateFrom, ucEmployeeFilter1.DateTo, DepartmentID, DesignationID, LocationID, EmployementTypeID); eReportType ReportType = (eReportType)cmbType.SelectedIndex; switch (ReportType) { case eReportType.LateComing: ds = ds.Where(r => r.LateIn).ToList(); break; case eReportType.EarlyGoing: ds = ds.Where(r => r.EarlyGoing).ToList(); break; case eReportType.MissedPunch: ds = ds.Where(r => r.MissedPunch).ToList(); break; } var filteredEmployees = (from r in ds group r by r.EmployeeID into gr select gr.Key); DataTable dt = new DataTable("dsReport" + DateTime.Now.Ticks.ToString()); dt.Columns.Add("EmployeeNoPrefix", typeof(string)); dt.Columns.Add("EmployeeNo", typeof(int)); dt.Columns.Add("EmployeeName", typeof(string)); //dt.Columns.Add("DepartmentName", typeof(string)); //dt.Columns.Add("DesignationName", typeof(string)); //dt.Columns.Add("LocationName", typeof(string)); //dt.Columns.Add("EmployementType", typeof(string)); for (DateTime r = ucEmployeeFilter1.DateFrom; r <= ucEmployeeFilter1.DateTo; r = r.AddDays(1)) { string dtname = r.ToString("ddMMyyyy"); dt.Columns.Add("ShiftName" + dtname, typeof(string)); if (ReportType != eReportType.EarlyGoing) { dt.Columns.Add("DTIN" + dtname, typeof(TimeSpan)); } if (ReportType != eReportType.LateComing) { dt.Columns.Add("DTOUT" + dtname, typeof(TimeSpan)); } } foreach (var emp in filteredEmployees) { var Employee = dsEmployeeLookup.Find(r => r.EmployeeID == emp); if (Employee == null || Employee.EmployeeID == -1) { continue; } DataRow dr = dt.Rows.Add(); //dr["EmployeeID"] = emp; dr["EmployeeName"] = Employee.EmployeeName; dr["EmployeeNoPrefix"] = Employee.EmployeeNoPrefix; dr["EmployeeNo"] = Employee.EmployeeNo; //dr["DepartmentName"] = Employee.Department; //dr["DesignationName"] = Employee.Designation; //dr["LocationName"] = Employee.Location; //dr["EmployementType"] = Employee.EmployementType; for (DateTime date = ucEmployeeFilter1.DateFrom; date <= ucEmployeeFilter1.DateTo; date = date.AddDays(1)) { var attendances = ds.Where(r => r.EmployeeID == emp && r.Day == date); foreach (var attendance in attendances) { if (attendance != null) { dr["ShiftName" + date.ToString("ddMMyyyy")] = attendance.EmployeeShiftName; if (attendance.InTime != null && ReportType != eReportType.EarlyGoing) { dr["DTIN" + date.ToString("ddMMyyyy")] = attendance.InTime; } if (attendance.OutTime != null && ReportType != eReportType.LateComing) { dr["DTOUT" + date.ToString("ddMMyyyy")] = attendance.OutTime; } } } } } dt.DefaultView.Sort = "EmployeeNo"; ClearGrid(); gridControlData.DataSource = dt;//.DefaultView.ToTable(); txtNofRecords.EditValue = dt.Rows.Count; GridBand EmployeeBand = new DevExpress.XtraGrid.Views.BandedGrid.GridBand() { Name = "EmployeeBand", Caption = "Employee", MinWidth = 100, }; EmployeeBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridViewData.Bands.Add(EmployeeBand); BandedGridColumn myGridColumn = null; myGridColumn = gridViewData.Columns["EmployeeNoPrefix"]; myGridColumn.Caption = "Prefix"; myGridColumn.MinWidth = 70; myGridColumn.MaxWidth = 100; //myGridColumn.SortIndex = 0; myGridColumn.OwnerBand = EmployeeBand; myGridColumn.Width = 100; myGridColumn.Visible = false; myGridColumn = gridViewData.Columns["EmployeeNo"]; myGridColumn.Caption = "No."; myGridColumn.MinWidth = 70; myGridColumn.MaxWidth = 100; //myGridColumn.SortIndex = 0; myGridColumn.OwnerBand = EmployeeBand; myGridColumn.Width = 100; myGridColumn.Visible = true; myGridColumn = gridViewData.Columns["EmployeeName"]; myGridColumn.Caption = "Name"; myGridColumn.MinWidth = 200; //myGridColumn.MaxWidth = 500; myGridColumn.OwnerBand = EmployeeBand; myGridColumn.Visible = true; myGridColumn.Width = 1000; //myGridColumn = gridViewData.Columns["DepartmentName"]; //myGridColumn.Caption = "Department"; //myGridColumn.MinWidth = 100; //myGridColumn.MaxWidth = 300; //myGridColumn.OwnerBand = EmployeeBand; //myGridColumn.Visible = false; //myGridColumn = gridViewData.Columns["DesignationName"]; //myGridColumn.Caption = "Designation"; //myGridColumn.MinWidth = 100; //myGridColumn.MaxWidth = 300; //myGridColumn.OwnerBand = EmployeeBand; //myGridColumn.Visible = false; //myGridColumn = gridViewData.Columns["LocationName"]; //myGridColumn.Caption = "Location"; //myGridColumn.MinWidth = 100; //myGridColumn.MaxWidth = 300; //myGridColumn.OwnerBand = EmployeeBand; //myGridColumn.Visible = false; //myGridColumn = gridViewData.Columns["EmployementType"]; //myGridColumn.Caption = "Employement Type"; //myGridColumn.MinWidth = 70; //myGridColumn.MaxWidth = 200; //myGridColumn.OwnerBand = EmployeeBand; //myGridColumn.Visible = false; int ColumnIndex = 0; for (DateTime r = ucEmployeeFilter1.DateFrom; r <= ucEmployeeFilter1.DateTo; r = r.AddDays(1)) { string dtname = r.ToString("ddMMyyyy"); //-- GridBand DateBand = new GridBand() { Name = "DateBand" + dtname, Caption = r.ToString("dd-MM-yyyy"), }; DateBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridViewData.Bands.Add(DateBand); //-- BandedGridColumn column = null; Color AlternateBackColor = Color.WhiteSmoke; column = gridViewData.Columns["ShiftName" + dtname]; column.Caption = "Shift"; column.MinWidth = 75; column.MaxWidth = 300; column.OwnerBand = DateBand; column.Width = 100; column.Visible = ShowShift; if ((ColumnIndex % 2 == 0)) { column.AppearanceCell.BackColor = AlternateBackColor; } if (ReportType != eReportType.EarlyGoing) { column = gridViewData.Columns["DTIN" + dtname]; column.Caption = "In"; column.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; column.DisplayFormat.FormatString = "hh\\:mm"; column.MinWidth = 55; column.MaxWidth = 100; column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column.OwnerBand = DateBand; column.Width = 100; column.Visible = true; if ((ColumnIndex % 2 == 0)) { column.AppearanceCell.BackColor = AlternateBackColor; } } if (ReportType != eReportType.LateComing) { column = gridViewData.Columns["DTOUT" + dtname]; column.Caption = "Out"; column.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; column.DisplayFormat.FormatString = "hh\\:mm"; column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column.OwnerBand = DateBand; column.MinWidth = 55; column.MaxWidth = 100; column.Width = 100; column.Visible = true; if ((ColumnIndex % 2 == 0)) { column.AppearanceCell.BackColor = AlternateBackColor; } } if (ReportType == eReportType.LateComing || ReportType == eReportType.EarlyGoing) { DateBand.Width = 100; } else { DateBand.Width = 200; } ColumnIndex++; } //-- gridControlData.RefreshDataSource(); gridViewData.BestFitColumns(); }
private void CreateColumns(DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand1, DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand2) { //***** 1 ********** //DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn1 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn2 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn3 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn4 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn5 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn6 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn7 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn8 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn9 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn10 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn11 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn12 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn13 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bandedGridColumn14 = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); //bandedGridColumn1.Caption = "Type"; //bandedGridColumn1.FieldName = "bcType"; //bandedGridColumn1.Visible = true; //bandedGridColumn1.RowCount = 2; bandedGridColumn2.Caption = "Size"; bandedGridColumn2.FieldName = "bcSize"; bandedGridColumn2.Visible = true; bandedGridColumn3.Caption = "Fabric No."; bandedGridColumn3.FieldName = "bcFabric"; bandedGridColumn3.Visible = true; bandedGridColumn4.Caption = "Vendor"; bandedGridColumn4.FieldName = "bcVendor"; bandedGridColumn4.Visible = true; bandedGridColumn5.Caption = "Garment" + Environment.NewLine + "Part"; bandedGridColumn5.FieldName = "bcGarmentPart"; bandedGridColumn5.Visible = true; bandedGridColumn6.Caption = "Color No."; bandedGridColumn6.FieldName = "bcColorNo"; bandedGridColumn6.Visible = true; bandedGridColumn7.Caption = "Color Name"; bandedGridColumn7.FieldName = "bcColorName"; bandedGridColumn7.Visible = true; bandedGridColumn8.Caption = "Width" + Environment.NewLine + "(All)"; bandedGridColumn8.FieldName = "bcWidthAll"; bandedGridColumn8.Visible = true; bandedGridColumn9.Caption = "Width" + Environment.NewLine + "(Use)"; bandedGridColumn9.FieldName = "bcWidthUse"; bandedGridColumn9.Visible = true; bandedGridColumn10.Caption = "g/m"; bandedGridColumn10.FieldName = "bcGM"; bandedGridColumn10.Visible = true; bandedGridColumn11.Caption = "m/1P"; bandedGridColumn11.FieldName = "bcM1P"; bandedGridColumn11.Visible = true; bandedGridColumn12.Caption = "kg/1P"; bandedGridColumn12.FieldName = "bcKg1P"; bandedGridColumn12.Visible = true; bandedGridColumn13.Caption = "Price" + Environment.NewLine + "(Baht)"; bandedGridColumn13.FieldName = "bcPrice"; bandedGridColumn13.Visible = true; bandedGridColumn14.Caption = "%Loss"; bandedGridColumn14.FieldName = "bcLoss"; bandedGridColumn14.Visible = true; //gridBand1.Columns.Add(bandedGridColumn1); gridBand1.Columns.Add(bandedGridColumn2); gridBand1.Columns.Add(bandedGridColumn3); gridBand1.Columns.Add(bandedGridColumn4); gridBand1.Columns.Add(bandedGridColumn5); gridBand1.Columns.Add(bandedGridColumn6); gridBand1.Columns.Add(bandedGridColumn7); gridBand1.Columns.Add(bandedGridColumn8); gridBand1.Columns.Add(bandedGridColumn9); gridBand1.Columns.Add(bandedGridColumn10); gridBand1.Columns.Add(bandedGridColumn11); gridBand1.Columns.Add(bandedGridColumn12); gridBand1.Columns.Add(bandedGridColumn13); gridBand1.Columns.Add(bandedGridColumn14); //***** 2 ********** List <string> listSize = new List <string>(); listSize.Add("S"); listSize.Add("M"); listSize.Add("S"); listSize.Add("M"); List <string> listColor = new List <string>(); listColor.Add("03 Gray"); listColor.Add("03 Gray"); listColor.Add("16 Red"); listColor.Add("16 Red"); int x = 0; foreach (string items in listColor) { DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bGridCol = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); bGridCol.Caption = listSize[x] + Environment.NewLine + items; bGridCol.FieldName = "BCS" + (x + 1).ToString(); bGridCol.Visible = true; gridBand2.Columns.Add(bGridCol); x++; } bgvFabric.ColumnPanelRowHeight = 38; bgvFabric.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; bgvFabric.Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bgvFabric.Appearance.BandPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bgvFabric.Appearance.FooterPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; for (int ii = 0; ii < bgvFabric.Columns.Count; ii++) { bgvFabric.Columns[ii].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; } if (bgvFabric.Columns.Count > 13) { for (int ii = 13; ii < bgvFabric.Columns.Count; ii++) { bgvFabric.Columns[ii].AppearanceHeader.BackColor = Color.FromArgb(255, 222, 222); } } bgvFabric.OptionsView.ColumnAutoWidth = false; bgvFabric.BestFitColumns(); //gridBand2.Columns.Add(listColumnColor); }
private void Form1Print_Load(object sender, EventArgs e) { if (!isselect) { barButtonItem4.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; } gridBand2.Visible = false; gridControl1.DataSource = GridDataTable; this.bandedGridView1.GroupPanelText = this.Text; //int numi = 0; //DevExpress.XtraGrid.Views.BandedGrid.GridBand[] gridBandDate = new DevExpress.XtraGrid.Views.BandedGrid.GridBand[listCount * 2]; //DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn[] gridColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn[listCount * 2]; foreach (DataColumn dc in GridDataTable.Columns) { if (dc.ColumnName.IndexOf("Äê") > 0) { gridBand2.Visible = true; DevExpress.XtraGrid.Views.BandedGrid.GridBand gbi = new DevExpress.XtraGrid.Views.BandedGrid.GridBand(); gbi.Caption = dc.ColumnName; gbi.Name = dc.ColumnName; gbi.AppearanceHeader.Options.UseTextOptions = true; gbi.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridBand2.Children.Add(gbi); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn gridColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); gridColumn.Caption = dc.ColumnName; gridColumn.FieldName = dc.ColumnName; gridColumn.Name = "Column" + dc.ColumnName; gridColumn.Visible = true; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; bandedGridView1.Columns.Add(gridColumn); gbi.Columns.Add(gridColumn); } if (dc.ColumnName.Substring(0, 1) == "S") { foreach (GridBand gc in bandedGridView1.Bands) { try { if (gc.Columns[0].FieldName == dc.ColumnName) { gc.Visible = true; // int i=dc.Caption.ToString().IndexOf("@"); gc.Caption = dc.Caption; // gc.VisibleIndex =int.Parse(dc.Caption.ToString().Substring(i-1,dc.Caption.Length- i)); gc.AppearanceHeader.Options.UseTextOptions = true; gc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; } } catch { } } //gbi =bandedGridView1.Bands; //gbi.Caption = dc.ColumnName; //gbi.Name = dc.ColumnName; //gbi.AppearanceHeader.Options.UseTextOptions = true; //gbi.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //gridBand2.Children.Add(gbi); //DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn gridColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); //gridColumn.Caption = dc.ColumnName; //gridColumn.FieldName = dc.ColumnName; //gridColumn.Name = "Column" + dc.ColumnName; //gridColumn.Visible = true; //gridColumn.DisplayFormat.FormatString = "n2"; //gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; //bandedGridView1.Columns.Add(gridColumn); //gbi.Columns.Add(gridColumn); } } //if (!isselect) //{ // //barButtonItem4.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; // this.Hide(); // ComponentPrint.ShowPreview(this.gridControl1, this.bandedGridView1.GroupPanelText); // this.Close(); //} //else //{ // title = this.bandedGridView1.GroupPanelText; // this.DialogResult = DialogResult.OK; //} }
private void Form1Print_Load(object sender, EventArgs e) { if (!isselect) { barButtonItem4.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; } gridBand2.Visible = false; gridControl1.DataSource = GridDataTable; this.bandedGridView1.GroupPanelText = this.Text; //int numi = 0; //DevExpress.XtraGrid.Views.BandedGrid.GridBand[] gridBandDate = new DevExpress.XtraGrid.Views.BandedGrid.GridBand[listCount * 2]; //DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn[] gridColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn[listCount * 2]; foreach (DataColumn dc in GridDataTable.Columns) { if (dc.ColumnName.IndexOf("Äê") > 0) { gridBand2.Visible = true; DevExpress.XtraGrid.Views.BandedGrid.GridBand gbi = new DevExpress.XtraGrid.Views.BandedGrid.GridBand(); gbi.Caption = dc.ColumnName; gbi.Name = dc.ColumnName; gbi.AppearanceHeader.Options.UseTextOptions = true; gbi.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridBand2.Children.Add(gbi); DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn gridColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); gridColumn.Caption = dc.ColumnName; gridColumn.FieldName = dc.ColumnName; gridColumn.Name = "Column"+dc.ColumnName; gridColumn.Visible = true; gridColumn.DisplayFormat.FormatString = "n2"; gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; bandedGridView1.Columns.Add(gridColumn); gbi.Columns.Add(gridColumn); } if (dc.ColumnName.Substring(0,1)=="S") { foreach (GridBand gc in bandedGridView1.Bands) { try { if (gc.Columns[0].FieldName == dc.ColumnName) { gc.Visible = true; // int i=dc.Caption.ToString().IndexOf("@"); gc.Caption = dc.Caption; // gc.VisibleIndex =int.Parse(dc.Caption.ToString().Substring(i-1,dc.Caption.Length- i)); gc.AppearanceHeader.Options.UseTextOptions = true; gc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; } } catch { } } //gbi =bandedGridView1.Bands; //gbi.Caption = dc.ColumnName; //gbi.Name = dc.ColumnName; //gbi.AppearanceHeader.Options.UseTextOptions = true; //gbi.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //gridBand2.Children.Add(gbi); //DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn gridColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); //gridColumn.Caption = dc.ColumnName; //gridColumn.FieldName = dc.ColumnName; //gridColumn.Name = "Column" + dc.ColumnName; //gridColumn.Visible = true; //gridColumn.DisplayFormat.FormatString = "n2"; //gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; //bandedGridView1.Columns.Add(gridColumn); //gbi.Columns.Add(gridColumn); } } //if (!isselect) //{ // //barButtonItem4.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; // this.Hide(); // ComponentPrint.ShowPreview(this.gridControl1, this.bandedGridView1.GroupPanelText); // this.Close(); //} //else //{ // title = this.bandedGridView1.GroupPanelText; // this.DialogResult = DialogResult.OK; //} }
private void CreateGrid() { int iCnt = 1; Graphics formGraphics = this.CreateGraphics(); for (int i = 0; i < GridView.Columns.Count; i++) { GridView.Columns[i].Width = (int)(GridView.Columns[i].Width * formGraphics.DpiX / 96); } for (int i = 0; i < m_list.Count; i++) { if (m_list[i].m_listSystemItems.Count == 0) { continue; } DevExpress.XtraGrid.Views.BandedGrid.GridBand gb = GridView.Bands.AddBand(m_list[i].m_strFunctionalSystemName); gb.OptionsBand.AllowMove = false; gb.AppearanceHeader.Options.UseTextOptions = true; gb.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gb.AppearanceHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; gb.AutoFillDown = true; gb.Name = "band_" + i.ToString(); for (int j = 0; j < m_list[i].m_listSystemItems.Count; j++) { BandedGridColumn col = new BandedGridColumn(); col.Name = m_list[i].m_listSystemItems[j].m_SystemItemID.ToString(); col.Caption = m_list[i].m_listSystemItems[j].m_strSystemItemName; col.OptionsColumn.AllowMove = false; col.OptionsColumn.AllowEdit = false; col.Width = (int)(150 * formGraphics.DpiX / 96); col.Visible = true; col.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.True; if (m_list[i].m_listSystemItems[j].m_strSystemItemName != m_list[i].m_strFunctionalSystemName) { DevExpress.XtraGrid.Views.BandedGrid.GridBand gb_ = gb.Children.AddBand(m_list[i].m_listSystemItems[j].m_strSystemItemName); gb_.OptionsBand.AllowMove = false; gb_.Width = (int)(150 * formGraphics.DpiX / 96); gb_.Columns.Add(col); gb_.AppearanceHeader.Options.UseTextOptions = true; gb_.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gb_.AppearanceHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; gb_.AutoFillDown = true; gb_.Name = "band_" + i.ToString() + "_" + j.ToString(); } else { gb.Columns.Add(col); } iCnt++; } } /*GridBandInfoArgs ex = null; * BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo; * viewInfo.GInfo.AddGraphics(null); * ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache); * try * { * ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), * new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), * StringAlignment.Near)); * ex.SetAppearance(GridView.Appearance.BandPanel); * ex.Caption = "А"; * ex.CaptionRect = new Rectangle(0, 0, 100, 100); * } * finally * { * viewInfo.GInfo.ReleaseGraphics(); * } * * GraphicsInfo grInfo = new GraphicsInfo(); * grInfo.AddGraphics(null); * ex.Cache = grInfo.Cache; * Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, "А"); * m_singleLineHeight = captionSize.Height;*/ BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo; m_singleLineHeight = viewInfo.BandRowHeight; GridView.BeginUpdate(); for (int i = 0; i < GridView.Bands.Count; i++) { int Width = 0; for (int j = 0; j < GridView.Bands[i].Children.Count; j++) { GridBand b = GridView.Bands[i].Children[j]; int child_height = GetColumnBestHeight(b, b.Width); b.RowCount = child_height / m_singleLineHeight; dictBandHeigths[b.Name] = child_height / m_singleLineHeight; Width += b.Width; } if (GridView.Bands[i].Children.Count > 0) { int parent_height = GetColumnBestHeight(GridView.Bands[i], Width); GridView.Bands[i].RowCount = parent_height / m_singleLineHeight; dictBandHeigths[GridView.Bands[i].Name] = parent_height / m_singleLineHeight; } } int max_parent_row = -1; int max_row = -1; for (int i = 0; i < GridView.Bands.Count; i++) { if (GridView.Bands[i].Children.Count > 0) { if (dictBandHeigths[GridView.Bands[i].Name] > max_parent_row) { max_parent_row = dictBandHeigths[GridView.Bands[i].Name]; } } for (int j = 0; j < GridView.Bands[i].Children.Count; j++) { GridBand b = GridView.Bands[i].Children[j]; if (dictBandHeigths[b.Name] > max_row) { max_row = dictBandHeigths[b.Name]; } } } for (int i = 0; i < GridView.Bands.Count; i++) { if (GridView.Bands[i].Children.Count > 0) { GridView.Bands[i].RowCount = max_parent_row; } for (int j = 0; j < GridView.Bands[i].Children.Count; j++) { GridBand b = GridView.Bands[i].Children[j]; b.RowCount = max_row; } } GridView.EndUpdate(); }