remove header 3d border style in gridgrouping?

How to remove this raised border effect on the headers and instead make them all blue with no gridlines?

Thanks


Image_6767_1734483304155


4 Replies

SB Sweatha Bharathi Syncfusion Team December 18, 2024 01:11 PM UTC

Hi ollie,


We have reviewed your scenario and your requirement regarding setting the background color of the header and removing the grid lines. This can be accomplished using the code snippet below. We have provided a sample for your reference. Kindly review the code sample and let us know if you have any concerns. If we have misunderstood your requirement, could you kindly clarify the following queries so we can proceed further:
1.Do you need to remove the lines in the header as well?
2. You mentioned removing the border effect. Can you confirm if any theme has been used or if you have set any BorderStyle?

 This information will help us proceed further.

Code Snippet :

  public Form1()
  {
      InitializeComponent();
      InitializeData();
          this.gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.BackColor = Color.Blue;
      this.gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.Themed = false;
      this.gridGroupingControl1.TableOptions.GridLineBorder = new GridBorder(GridBorderStyle.None);

  }



Regards,

Sweatha.B


Attachment: GridGroupingControl_Demo4_8_13370cdd.zip


OL ollie December 18, 2024 10:11 PM UTC

I haven't set a borderstyle, and I would like lines removed so that the header is completely blue

Thanks



SB Sweatha Bharathi Syncfusion Team December 19, 2024 01:40 PM UTC

Hi ollie,


We have reviewed your scenario. Currently, we are drawing the header line using a rectangle with a 3D frame, which applies both the line and border effects. We are exploring the possibility of providing a workaround to remove the border from the header lines. We need time to validate the scenario and will provide an update with further details on or before December 23, 2024

Regards,

Sweatha.B






SB Sweatha Bharathi Syncfusion Team December 23, 2024 02:22 PM UTC

Hi ollie,

As mentioned in a previous update, the header line is drawn using a rectangle with a 3D frame. To resolve this, we can override the GridTableHeaderCellRenderer and draw the rectangle with a transparent color. Kindly refer to the code snippet below, We have provide a sample for your reference. Please review the sample and let us know if you have any concerns


Code Snippet:

// For make the header to be blue

 this.gridGroupingControl1.TableOptions.GridLineBorder = new GridBorder(GridBorderStyle.None);
 this.gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.BackColor = Color.Blue;
 this.gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.Themed = false;

// Overiding GridTableHeaderCellRenderer

 public Form1()
 {
 
     InitializeComponent();
    this.gridGroupingControl1.TableControl.CellRenderers["ColumnHeaderCell"] = new GridHeaderCellRenderer(gridGroupingControl1.TableControl, new GridExcelFilterCellModelAdv(gridGroupingControl1.TableModel));

 }

 public class GridHeaderCellRenderer : GridTableHeaderCellRenderer
 {
     public GridHeaderCellRenderer(GridControlBase grid, GridCellModelBase cellModel) : base(grid, cellModel)
     {

     }
     protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
     {
         Rectangle rc;

         int x0 = clientRectangle.Left;
         int y0 = clientRectangle.Top;
         int x1 = clientRectangle.Right;
         int y1 = clientRectangle.Bottom;

         // Draw the top border
         using (Brush brTL = new SolidBrush(Color.Transparent))
         {
             rc = Rectangle.FromLTRB(x0, y0, x1, y0 + 1);
             g.FillRectangle(brTL, rc);
         }

         // Draw the bottom border
         using (Brush brBR = new SolidBrush(Color.Transparent))
         {
             rc = Rectangle.FromLTRB(x0, y1, x1 + 1, y1 + 1);
             g.FillRectangle(brBR, rc);
         }

         // Left
         using (Brush brBR = new SolidBrush(Color.Transparent))
         {
             rc = Rectangle.FromLTRB(x0, y0, x0 + 1, y1);
             g.FillRectangle(brBR, rc);

         }

         // Right
         using (Brush brBR = new SolidBrush(Color.Transparent))
         {
             rc = Rectangle.FromLTRB(x1, y0, x1 + 1, y1);
             g.FillRectangle(brBR, rc);
         }

         this.OnDrawDisplayText(g, clientRectangle, rowIndex, colIndex, style);          
     }
 }

 public class GridExcelFilterCellModelAdv : GridHeaderCellModel
 {
     public GridExcelFilterCellModelAdv(GridModel grid)
      : base(grid)
     {
         
     }
     public override GridCellRendererBase CreateRenderer(GridControlBase control)
     {
         return new GridHeaderCellRenderer(control, this);
     }
 }



Image Reference:



Attachment: GridGroupingControl_Demo4_8_449a6aad.zip

Loader.
Up arrow icon