总是感觉这种样式有点怪怪的,如下:
总想让这个表格更普通化一点,如下:
于是用到了下面这些代码:
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
private void gView_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
{
GridGroupRowInfo groupRowInfo = e.Info as GridGroupRowInfo;
Rectangle groupRowBounds = groupRowInfo.DataBounds;
Rectangle expandButtonBounds = groupRowInfo.ButtonBounds;
Rectangle textBounds = e.Bounds;
textBounds.X = expandButtonBounds.Right + 4;
Brush brushText = Brushes.Black, brushTextShadow = Brushes.White;
string s = gView.GetGroupRowDisplayText(e.RowHandle);
e.Appearance.DrawString(e.Cache, s, textBounds, brushText);
e.Handled = true;
}
private void gView_GroupRowCollapsing(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e)
{
e.Allow = false;
}
private void gView_CustomDrawRowFooter(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
{
Brush brush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.White, Color.White, 90);
e.Graphics.FillRectangle(brush, e.Bounds);
e.Handled = true;
}