Can i add particular color for entire Row or Column in TableLayoutPanel ? How ? please provide sample code if any ..
Thanks in adv.
Yes you can.
Use the TableLayoutPanel's CellPaint event to test for which row/column has called the event and then use a Graphic object size to the rectangle to set the cell's color.
Like this (for the first and third rows):
private void Form_Load(object sender, EventArgs e) {
this.tableLayoutPanel1.CellPaint += new TableLayoutCellPaintEventHandler(tableLayoutPanel1_CellPaint);
}
void tableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
{
if (e.Row == 0 || e.Row == 2) {
Graphics g = e.Graphics;
Rectangle r = e.CellBounds;
g.FillRectangle(Brushes.Blue, r);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With