private void Form_Load(object sender, EventArgs e)
{
table.BeforePaintCell += new PaintCellEventHandler(table_BeforePaintCell);
}
private void table_BeforePaintCell(object sender, PaintCellEventArgs e)
{
// draw a checkerboard style table
if ((e.Row + e.Column) % 2 == 0)
{
e.Graphics.FillRectangle(Brushes.Black, e.CellRect);
e.Graphics.DrawString(e.Cell.Text, e.Cell.Font, Brushes.White, e.CellRect);
// must set e.Handled to true otherwise the table
// may erase what we've just done (depends on what
// the cell and row background colors are but we
// don't want to take that chance)
e.Handled = true;
}
}
private void Form_Load(object sender, EventArgs e)
{
table.AfterPaintCell += new PaintCellEventHandler(table_AfterPaintCell);
}
private void table_AfterPaintCell(object sender, PaintCellEventArgs e)
{
// draw a blue box around the cell if it is
// in an even row and column number
if (e.Column % 2 == 0 && e.Row % 2 == 0)
{
e.Graphics.DrawRectangle(Pens.Blue, e.CellRect.X, e.CellRect.Y, e.CellRect.Width-1, e.CellRect.Height-1);
}
// draw a red box around the cell if it is
// in an odd row and column number
if (e.Column % 2 == 1 && e.Row % 2 == 1)
{
e.Graphics.DrawRectangle(Pens.Red, e.CellRect.X, e.CellRect.Y, e.CellRect.Width-1, e.CellRect.Height-1);
}
// no need to set e.Handled property as the table
// has already drawn the cell for us
}
private void table2_AfterPaintCell(object sender, XPTable.Events.PaintCellEventArgs e)
{
if ( tableModel2.Selections.IsRowSelected(e.Row))
{
foreach (Row item in tableModel2.Selections.SelectedItems)
{
if (e.Column == 0)
{
Row row = tableModel2.Rows[e.Row];
Rectangle r = table2.RowRect(row);
r.Width = table2.Width;
e.Graphics.DrawRectangle(Pens.Blue, r);
}
}
}
}