PDA

View Full Version : سوال: چگونگی استفاده از تابع OnCellPain



alexmcse
یک شنبه 20 اسفند 1391, 16:13 عصر
سلام
protected override void OnCellPaint در تابع زیر چطور به تابع دسترسی داشته باشیم واز آن استفاده کنیم
کد بنویسید لطفا

public class DemoTableLayoutPanel : TableLayoutPanel
{
protected override void OnCellPaint(TableLayoutCellPaintEventArgs e)
{
base.OnCellPaint(e);

Control c = this.GetControlFromPosition(e.Column, e.Row);

if ( c != null )
{
Graphics g = e.Graphics;

g.DrawRectangle(
Pens.Red,
e.CellBounds.Location.X+1,
e.CellBounds.Location.Y + 1,
e.CellBounds.Width - 2, e.CellBounds.Height - 2);

g.FillRectangle(
Brushes.Blue,
e.CellBounds.Location.X + 1,
e.CellBounds.Location.Y + 1,
e.CellBounds.Width - 2,
e.CellBounds.Height - 2);
};
}

}