thank you for the code. It helped, but it did not solved my problem completly. What I need is the first collumn header devided into two equally looking parts. The parts look like buttons, the first part is the newly add button, the second part is the rest of the collumn header. What I have reached so far is not what I want. The first, newly added button is not raised everytime, and it does not look to be equally high like the rest of the collumn header.
So how to devide the collumn header into two equally looking parts?
Thank you! Regads Dan
Thank you for being patience.
Resize the button
You can resize the button by override the OnLayout method of the renderer class. In the method, the required position and size can be specified to draw the button in the required size inside the cell. Please refer to the code snippet below for more details.
To place the button in a certain position within the collumn-header
Please refer to the following code snippet demonstrates the grid being drawn in the required position inside the cell by override the OnLayout method of the renderer class.
public class HeaderCellButtonRenderer : GridStaticCellRenderer
public HeaderCellButtonRenderer(GridControlBase grid, GridCellModelBase cellModel)
: base(grid, cellModel)
m_headerButton = new HeaderCellButton(this);
m_headerButton.Interior = new BrushInfo(System.Drawing.SystemColors.ButtonFace);
m_headerButton.Bounds = new Rectangle(new Point(0, 0),
new Size(cellModel.GetCellSize(0, 1).Width / 2,
m_headerButton.Graphics = grid.CreateGraphics();
m_headerButton.ButtonState = ButtonState.Normal;
m_headerButton.GridStyleInfo = new GridStyleInfo();
protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle buttonsBounds)
TraceUtil.TraceCurrentMethodInfo(rowIndex, colIndex, style, innerBounds, buttonsBounds);
// Here you specify where the button should be drawn within the cell.
Rectangle rightArea = Rectangle.FromLTRB(innerBounds.Right - 50, innerBounds.Top, innerBounds.Right, innerBounds.Bottom);
buttonsBounds = GridUtil.CenterInRect(rightArea, new Size(30, 20));
// Here you return the area where the text should be drawn/edited.
innerBounds.Width -= 20;
Kindly let us know if you need any further assistance.
Have a nice day.