mercoledì 20 ottobre 2010

DevExpress, XtraGrid, Impostare un background per L'Header da codice





void  gridView_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)

{
      if (e.Column == null) return;
      GridView gView = (GridView)sender;
      if (gView.RowCount != 0 && (gView.GetRow(0) is GuiVenditaDetailEI || gView.GetRow(0) is GuiVenditaDetailEIDetail ))
      {
          Rectangle rect = e.Bounds;
          ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
          SolidBrush brush = new SolidBrush(Color.FromKnownColor(KnownColor.WhiteSmoke)); 


          rect.Inflate(-1, -1);
          // Fill column headers with the specified colors.
          e.Graphics.FillRectangle(brush, rect);
          e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect);
          // Draw the filter and sort buttons.
          foreach (DevExpress.Utils.Drawing.DrawElementInfo info in e.Info.InnerElements)
          {
                 DevExpress.Utils.Drawing.ObjectPainter.DrawObject(e.Cache, info.ElementPainter,info.ElementInfo);
          }
          e.Handled = true;
}

0 commenti:

Posta un commento