private int GetColumnBestHeight(GridBand column, int width, DevExpress.Utils.AppearanceObject app) { 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(app); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, (int)(width - 10 * DpiXRel), 1000); } finally { viewInfo.GInfo.ReleaseGraphics(); } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; int Height = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption); return(Height); }
public MyToolButtonDrawEventArgs(DevExpress.Utils.AppearanceObject appearance, MyToolButtonViewInfo viewInfo, DevExpress.Utils.Drawing.GraphicsCache cache) { this.appearance = appearance; this.viewInfo = viewInfo; this.cache = cache; }
private void DrawString(ControlGraphicsInfoArgs info, DevExpress.Utils.AppearanceObject appearance, ref Rectangle valRect, string str) { int width = TextUtils.GetStringSize(info.Graphics, str, appearance.Font).Width; valRect.Width = width; base.DrawString(info, valRect, str, appearance); valRect.X += width; }
public static void SetAppearance(DevExpress.Utils.AppearanceObject appearance, Color backColor, Color borderColor) { appearance.BackColor = backColor; appearance.BorderColor = borderColor; appearance.FontSizeDelta = -2; appearance.ForeColor = Color.White; appearance.Options.UseBackColor = true; appearance.Options.UseBorderColor = true; appearance.Options.UseFont = true; appearance.Options.UseForeColor = true; }
protected override void DrawText(ControlGraphicsInfoArgs info) { int scrollPosition = GetScrollPosition(info); DevExpress.Utils.AppearanceObject appearance = info.ViewInfo.Appearance; Rectangle bounds = (info.ViewInfo as ButtonEditViewInfo).MaskBoxRect; string displayText = info.ViewInfo.DisplayText; bounds.Offset(0, scrollPosition); bounds.Height = info.Graphics.MeasureString(displayText, appearance.GetFont()).ToSize().Height; appearance.DrawString(info.Cache, displayText, bounds); }
protected override DevExpress.Utils.AppearanceObject[] GetRowMixAppearances(GridCellInfo cellInfo, GridRowCellState state, GridRowInfo bi, DevExpress.Utils.AppearanceObjectEx column, DevExpress.Utils.AppearanceObject focusedCell, DevExpress.Utils.AppearanceObjectEx conditionCell) { DevExpress.Utils.AppearanceObject[] apps = base.GetRowMixAppearances(cellInfo, state, bi, column, focusedCell, conditionCell); if ((state & GridRowCellState.Selected) != 0) { apps.SetValue(PaintAppearance.SelectedRow, 0); } return(apps); }
internal void SetTexAlign(DevExpress.Utils.AppearanceObject pAppearanceObject) { switch (this.DataType) { case BoDataType.dt_LONG_NUMBER: case BoDataType.dt_SHORT_NUMBER: case BoDataType.dt_QUANTITY: case BoDataType.dt_PRICE: case BoDataType.dt_RATE: case BoDataType.dt_MEASURE: case BoDataType.dt_SUM: case BoDataType.dt_PERCENT: pAppearanceObject.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; break; case BoDataType.dt_LONG_TEXT: case BoDataType.dt_SHORT_TEXT: case BoDataType.dt_DATE: default: pAppearanceObject.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; break; } }
private void grvChoGiaiQuyet_GridStyles(DevExpress.Utils.AppearanceObject pAppearance, string FieldName, int RowIndex, bool IsRow) { var row = grvChoGiaiQuyet.GetRow(RowIndex); if (row == null) { return; } if (IsRow)//Cho phép thiết lập mầu sắc cho cả dòng. { if (row.LenhDienThoai.ToUpper() == "SÂN BAY".ToUpper() || row.SanBay_DuongDai == "1") { pAppearance.BackColor = Config_Common.Grid_CuocSanBay_BackGround; } } else//Cho phép thiết mầu sắc cho từ ô dữ liệu { if (FieldName.Contains("DiaChiDonKhach") && row.FT_IsFT && row.G5_Type == Enum_G5_Type.CuocKhongXeApp) { pAppearance.BackColor = Color.Yellow; } } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); DevExpress.Utils.AppearanceObject appearanceObject1 = new DevExpress.Utils.AppearanceObject(); this.gridControl1 = new DevExpress.XtraGrid.GridControl(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); this.dataSet1 = new System.Data.DataSet(); this.dataTable1 = new System.Data.DataTable(); this.dataColumn2 = new System.Data.DataColumn(); this.dataColumn3 = new System.Data.DataColumn(); this.dataColumn4 = new System.Data.DataColumn(); this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView(); this.colOrderItem = new DevExpress.XtraGrid.Columns.GridColumn(); this.colShipCountry = new DevExpress.XtraGrid.Columns.GridColumn(); this.colIsFreeShipping = new DevExpress.XtraGrid.Columns.GridColumn(); this.gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn(); this.behaviorManager1 = new DevExpress.Utils.Behaviors.BehaviorManager(this.components); this.disabledCellEvents1 = new DevExpress.Utils.Behaviors.Common.DisabledCellEvents(this.components); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataTable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.behaviorManager1)).BeginInit(); this.SuspendLayout(); // // gridControl1 // this.gridControl1.DataSource = this.bindingSource1; this.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.gridControl1.EmbeddedNavigator.Margin = new System.Windows.Forms.Padding(2); this.gridControl1.Location = new System.Drawing.Point(0, 0); this.gridControl1.MainView = this.gridView1; this.gridControl1.Margin = new System.Windows.Forms.Padding(2); this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(605, 286); this.gridControl1.TabIndex = 0; this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView1 }); // // bindingSource1 // this.bindingSource1.DataMember = "Orders"; this.bindingSource1.DataSource = this.dataSet1; // // dataSet1 // this.dataSet1.DataSetName = "NewDataSet"; this.dataSet1.Tables.AddRange(new System.Data.DataTable[] { this.dataTable1 }); // // dataTable1 // this.dataTable1.Columns.AddRange(new System.Data.DataColumn[] { this.dataColumn2, this.dataColumn3, this.dataColumn4 }); this.dataTable1.TableName = "Orders"; // // dataColumn2 // this.dataColumn2.ColumnName = "OrderItem"; // // dataColumn3 // this.dataColumn3.ColumnName = "ShipCountry"; // // dataColumn4 // this.dataColumn4.ColumnName = "IsFreeShipping"; this.dataColumn4.DataType = typeof(bool); // // gridView1 // this.behaviorManager1.SetBehaviors(this.gridView1, new DevExpress.Utils.Behaviors.Behavior[] { ((DevExpress.Utils.Behaviors.Behavior)(DevExpress.Utils.Behaviors.Common.DisabledCellBehavior.Create(typeof(DevExpress.XtraGrid.Extensions.GridViewDisabledCellSource), "[ShipCountry] = \'US\' Or [ShipCountry] = \'Canada\'", appearanceObject1, this.disabledCellEvents1))) }); this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] { this.colOrderItem, this.colShipCountry, this.colIsFreeShipping, this.gridColumn1 }); this.gridView1.GridControl = this.gridControl1; this.gridView1.Name = "gridView1"; this.gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; // // colOrderItem // this.colOrderItem.FieldName = "OrderItem"; this.colOrderItem.Name = "colOrderItem"; this.colOrderItem.Visible = true; this.colOrderItem.VisibleIndex = 0; // // colShipCountry // this.colShipCountry.FieldName = "ShipCountry"; this.colShipCountry.Name = "colShipCountry"; this.colShipCountry.Visible = true; this.colShipCountry.VisibleIndex = 1; // // colIsFreeShipping // this.colIsFreeShipping.Caption = "Disabled using an event"; this.colIsFreeShipping.FieldName = "IsFreeShipping"; this.colIsFreeShipping.Name = "colIsFreeShipping"; this.colIsFreeShipping.Visible = true; this.colIsFreeShipping.VisibleIndex = 2; // // gridColumn1 // this.gridColumn1.Caption = "Disabled using an Expression"; this.gridColumn1.FieldName = "Unbound"; this.gridColumn1.Name = "gridColumn1"; this.gridColumn1.UnboundExpression = "[IsFreeShipping]"; this.gridColumn1.UnboundType = DevExpress.Data.UnboundColumnType.Boolean; this.gridColumn1.Visible = true; this.gridColumn1.VisibleIndex = 3; // // disabledCellEvents1 // this.disabledCellEvents1.ProcessingCell += new System.EventHandler <DevExpress.Utils.Behaviors.Common.ProcessCellEventArgs>(this.disabledCellEvents1_ProcessingCell); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(605, 286); this.Controls.Add(this.gridControl1); this.Margin = new System.Windows.Forms.Padding(2); this.Name = "MainForm"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.behaviorManager1)).EndInit(); this.ResumeLayout(false); }
protected override DevExpress.Utils.AppearanceObject RaiseGetRowStyle(int rowHandle, DevExpress.XtraGrid.Views.Base.GridRowCellState state, DevExpress.Utils.AppearanceObject appearance, out bool highPriority) { DataRow r = this.GetDataRow(rowHandle); if (r != null) { if (ToolKit.ParseBoolen(r["IsFresh"])) { appearance.BackColor = Color.FromArgb(212, 231, 176); } else { appearance.BackColor = Color.White; } } else { appearance.BackColor = Color.White; } return(base.RaiseGetRowStyle(rowHandle, state, appearance, out highPriority)); }
/// <summary> /// 当需要自定义特殊修改实现此事件 /// </summary> /// <param name="p_RowObject"></param> /// <param name="p_SchemeColor"></param> /// <param name="appearance"></param> private void gridView1_SetRowColorChange(object p_RowObject, _SchemeColor p_SchemeColor, DevExpress.Utils.AppearanceObject appearance) { DataRowView info = (p_RowObject as DataRowView); if (!info["YSBH"].Equals(info["BH"]) && !info["YSDW"].Equals(info["DW"]) && !info["YSMC"].Equals(info["MC"])) { //获取特殊样式绑定颜色 _SpecialStyleInfo style = p_SchemeColor.SpecialStyle.Get("市场单价修改"); if (style != null) { appearance.Font = new Font(appearance.Font.FontFamily, appearance.Font.Size, style.Font); //字体颜色 appearance.ForeColor = style.ForeColor.IsEmpty ? appearance.ForeColor : style.ForeColor; //背景颜色 appearance.BackColor = style.BColor.IsEmpty ? appearance.BackColor : style.BColor; appearance.BackColor2 = style.BColor2.IsEmpty ? appearance.BackColor2 : style.BColor2; } } if (!info["SCDJ"].Equals(info["DEDJ"])) { //获取特殊样式绑定颜色 _SpecialStyleInfo style = p_SchemeColor.SpecialStyle.Get("市场单价修改"); if (style != null) { appearance.Font = new Font(appearance.Font.FontFamily, appearance.Font.Size, style.Font); //字体颜色 appearance.ForeColor = style.ForeColor.IsEmpty ? appearance.ForeColor : style.ForeColor; //背景颜色 appearance.BackColor = style.BColor.IsEmpty ? appearance.BackColor : style.BColor; appearance.BackColor2 = style.BColor2.IsEmpty ? appearance.BackColor2 : style.BColor2; } } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); DevExpress.Utils.AppearanceObject appearanceObject1 = new DevExpress.Utils.AppearanceObject(); this.gridControl1 = new DevExpress.XtraGrid.GridControl(); this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView(); this.gridView2 = new DevExpress.XtraGrid.Views.Grid.GridView(); this.behaviorManager1 = new DevExpress.Utils.Behaviors.BehaviorManager(this.components); this.disabledCellEvents1 = new DevExpress.Utils.Behaviors.Common.DisabledCellEvents(this.components); this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl(); this.Root = new DevExpress.XtraLayout.LayoutControlGroup(); this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.behaviorManager1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit(); this.layoutControl1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); this.SuspendLayout(); // // gridControl1 // this.gridControl1.Location = new System.Drawing.Point(12, 12); this.gridControl1.MainView = this.gridView1; this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(721, 564); this.gridControl1.TabIndex = 0; this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView1, this.gridView2 }); // // gridView1 // this.behaviorManager1.SetBehaviors(this.gridView1, new DevExpress.Utils.Behaviors.Behavior[] { ((DevExpress.Utils.Behaviors.Behavior)(DevExpress.Utils.Behaviors.Common.DisabledCellBehavior.Create(typeof(DevExpress.XtraGrid.Extensions.GridViewDisabledCellSource), "", appearanceObject1, this.disabledCellEvents1))) }); this.gridView1.GridControl = this.gridControl1; this.gridView1.Name = "gridView1"; // // gridView2 // this.gridView2.GridControl = this.gridControl1; this.gridView2.Name = "gridView2"; // // layoutControl1 // this.layoutControl1.Controls.Add(this.gridControl1); this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.layoutControl1.Location = new System.Drawing.Point(0, 0); this.layoutControl1.Name = "layoutControl1"; this.layoutControl1.Root = this.Root; this.layoutControl1.Size = new System.Drawing.Size(745, 588); this.layoutControl1.TabIndex = 2; this.layoutControl1.Text = "layoutControl1"; // // Root // this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True; this.Root.GroupBordersVisible = false; this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] { this.layoutControlItem1 }); this.Root.Name = "Root"; this.Root.Size = new System.Drawing.Size(745, 588); this.Root.TextVisible = false; // // layoutControlItem1 // this.layoutControlItem1.Control = this.gridControl1; this.layoutControlItem1.Location = new System.Drawing.Point(0, 0); this.layoutControlItem1.Name = "layoutControlItem1"; this.layoutControlItem1.Size = new System.Drawing.Size(725, 568); this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem1.TextVisible = false; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(745, 588); this.Controls.Add(this.layoutControl1); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridView2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.behaviorManager1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit(); this.layoutControl1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); this.ResumeLayout(false); }
private void HienThiAnhTrangThai_MauChu(DataRow cuocGoi, bool IsRow, int RowIndex, string colName, object valueCell, DevExpress.Utils.AppearanceObject style) { try { if (colName != null && colName.Equals("PhoneNumber")) { // thay doi mau nen cua khach VIP, moi gioi, khach binh thuong if ((KieuKhachHangGoiDen)Convert.ToInt16(cuocGoi["KieuKhachHangGoiDen"]) == KieuKhachHangGoiDen.KhachHangMoiGioi) { style.BackColor = Color.Yellow; } else if ((KieuKhachHangGoiDen)Convert.ToInt16(cuocGoi["KieuKhachHangGoiDen"]) == KieuKhachHangGoiDen.KhachHangVIP) { style.BackColor = Color.Blue; } else if ((KieuKhachHangGoiDen)Convert.ToInt16(cuocGoi["KieuKhachHangGoiDen"]) == KieuKhachHangGoiDen.KhachHangVang || (KieuKhachHangGoiDen)Convert.ToInt16(cuocGoi["KieuKhachHangGoiDen"]) == KieuKhachHangGoiDen.KhachHangBac) { style.BackColor = Color.ForestGreen; } else if ((KieuKhachHangGoiDen)Convert.ToInt16(cuocGoi["KieuKhachHangGoiDen"]) == KieuKhachHangGoiDen.KhachHangKhongHieu) { style.BackColor = Color.LightSalmon; } } } catch (Exception ex) { LogError.WriteLogError("HienThiAnhTrangThai_MauChu: ", ex); } }
private void DrawContent(ControlGraphicsInfoArgs info, Rectangle bounds, string text, DevExpress.Utils.AppearanceObject appearance) { PopupContainerEditViewInfo viewInfo = info.ViewInfo as PopupContainerEditViewInfo; RepositoryItemCheckedImageComboBoxEdit edit = viewInfo.Item as RepositoryItemCheckedImageComboBoxEdit; string[] values = text.Split(edit.SeparatorChar); Rectangle valRect = new Rectangle(bounds.X, bounds.Y, 0, bounds.Height); foreach (string val in values) { int index = GetIndexByDescription(edit.GetItems(), val.Trim()); if (index != -1) { DrawImage(edit, info.Graphics, index, ref valRect); } string str = val; if (Array.IndexOf(values, val) < values.Length - 1) { str = string.Concat(val, edit.SeparatorChar); } DrawString(info, appearance, ref valRect, str); } }
protected override void DrawString(ControlGraphicsInfoArgs info, Rectangle bounds, string text, DevExpress.Utils.AppearanceObject appearance) { PopupContainerEditViewInfo viewInfo = info.ViewInfo as PopupContainerEditViewInfo; RepositoryItemCheckedImageComboBoxEdit edit = viewInfo.Item as RepositoryItemCheckedImageComboBoxEdit; if (!edit.CanShowImageInEditBox) { base.DrawString(info, bounds, text, appearance); } else { DrawContent(info, bounds, text, appearance); } }
private void gridView1_SetRowColorChange(object p_RowObject, _SchemeColor p_SchemeColor, DevExpress.Utils.AppearanceObject appearance) { _ObjectQuantityUnitInfo info = (p_RowObject as _ObjectQuantityUnitInfo); if (info.YSBH == info.BH && info.YSDW == info.DW && info.YSMC == info.MC && info.SCDJ != info.DEDJ) { //获取特殊样式绑定颜色 _SpecialStyleInfo style = p_SchemeColor.SpecialStyle.Get("市场单价修改"); if (style != null) { appearance.Font = new Font(appearance.Font.FontFamily, appearance.Font.Size, style.Font); //字体颜色 appearance.ForeColor = style.ForeColor.IsEmpty ? appearance.ForeColor : style.ForeColor; //背景颜色 appearance.BackColor = style.BColor.IsEmpty ? appearance.BackColor : style.BColor; appearance.BackColor2 = style.BColor2.IsEmpty ? appearance.BackColor2 : style.BColor2; } } }