Hi Lamis,
You can use the DataGridView.CellPainting event to add custom drawing to any
cell. Set the DataGridViewCellPaintingEventArgs.Handled property to prevent
the custom drawing to be erased.
This code will add a magenta rectangle on top of any column called "Button",
in this case this happens to be a DataGridViewButtonColumn.
protected override void OnLoad(EventArgs e)
{
DataGridViewButtonColumn bc = new DataGridViewButtonColumn();
bc.Name = "Button";
dataGridView1.Columns.Add(bc);
dataGridView1.CellPainting += new
DataGridViewCellPaintingEventHandler(dataGridView1_CellPainting);
}
void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == -1 || e.RowIndex == -1)
return;
if (dataGridView1.Columns[e.ColumnIndex].Name == "Button")
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All);
e.Graphics.FillRectangle(Brushes.Magenta, e.CellBounds.Left
+ 10, e.CellBounds.Top + 5, 10, 10);
e.Handled = true;
}
}

Signature
Happy Coding!
Morten Wennevik [C# MVP]
> Hi
> this is my code
[quoted text clipped - 6 lines]
>
> Any idea how to do that??