Hi,
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
--
>Hi Dan,
Thank you for being patience.
Issue 1:
Resize the button
Solution:
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.
Issue 2:
To place the button in a certain position within the collumn-header
Solution:
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.
>>>>>>>>>>Code Snippet<<<<<<<<<<<<
public class HeaderCellButtonRenderer : GridStaticCellRenderer
{
HeaderCellButton m_headerButton;
public HeaderCellButtonRenderer(GridControlBase grid, GridCellModelBase cellModel)
: base(grid, cellModel)
{
m_headerButton = new HeaderCellButton(this);
AddButton(m_headerButton);
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,
cellModel.GetCellSize(0, 1).Height));
m_headerButton.Graphics = grid.CreateGraphics();
m_headerButton.ButtonState = ButtonState.Normal;
m_headerButton.GridStyleInfo = new GridStyleInfo();
m_headerButton.Draw(1, 1);
}
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[0] = GridUtil.CenterInRect(rightArea, new Size(30, 20));
// Here you return the area where the text should be drawn/edited.
innerBounds.Width -= 20;
return innerBounds;
}
}
>>>>>>>>>>Code Snippet<<<<<<<<<<<<
Kindly let us know if you need any further assistance.
Have a nice day.
Best regards,
Madhan
code19.zip