Description:
I use custom drawing for a Master-Detail View in my GridControl. Whenever I draw the cells in the first column, the expand button for the Detail view disappears. How can I draw the expand button in this situation?
Answer:
It's possible to paint expand buttons using exactly the same methods that the XtraGrid uses itself. Here is some sample code showing how this can be implemented:
C#
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.Utils.Drawing; ...
private void gridView1_CustomDrawCell(object sender,DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
GridCellInfo cell = e.Cell as GridCellInfo;
GridView view = sender as GridView;
ObjectPainter p = cell.RowInfo.ViewInfo.Painter.ElementsPainter.DetailButton;
if (!cell.CellButtonRect.IsEmpty)
{
ObjectPainter.DrawObject(e.Cache, p, new DevExpress.XtraGrid.Drawing.DetailButtonObjectInfoArgs(cell.CellButtonRect, view.GetMasterRowExpanded(cell.RowHandle), cell.RowInfo.IsMasterRowEmpty));
} ...
e.Handled = true;
}
See Also:
How to hide disabled expand/collapse buttons for master rows without detail records