110,533
社区成员
发帖
与我相关
我的任务
分享
if (e.RowIndex >= 0)
{
Rectangle newRect = new Rectangle(e.CellBounds.X + 1,e.CellBounds.Y + 1, e.CellBounds.Width - 4,e.CellBounds.Height - 4);
using (Brush gridBrush = new SolidBrush(this.SymbolViewList.GridColor),backColorBrush = new SolidBrush(e.CellStyle.BackColor))
{
using (Pen gridLinePen = new Pen(gridBrush))
{
e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,e.CellBounds.Bottom - 1);
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,e.CellBounds.Top, e.CellBounds.Right - 1,e.CellBounds.Bottom);
e.Graphics.DrawRectangle(Pens.Black, newRect);
if (e.Value != null)
{
if (e.Value.ToString().Length != 0)
{
if (e.RowIndex == rowIndext && e.ColumnIndex == colIndex)//当前被选中的单元格
{
e.Graphics.FillRectangle(Brushes.Orange, e.CellBounds);
}
e.Graphics.DrawString(Convert.ToString(((Image)e.Value).Tag), e.CellStyle.Font, Brushes.Crimson, e.CellBounds.X + 50, e.CellBounds.Y + 95, StringFormat.GenericDefault);
e.Graphics.DrawImage((Image)e.Value, new Point(e.CellBounds.X, e.CellBounds.Y));
}
}
e.Handled = true;
}
}