"Data collection from the network"
In the DataGridView cellpainting event, add the following code
private void Datagridview1_cellpainting (object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.rowindex >= 0 && E.columnindex = = 1)
{
Rectangle newrect = new Rectangle (e.cellbounds.x, E.cellbounds.y, E.cellbounds.height, e.cellbounds.height);
Create a new icon
System.Drawing.Icon ico = new Icon ("F://xx.ico");
using (Brush Gridbrush = new SolidBrush (This.dataGridView1.GridColor),
BackColorBrush = new SolidBrush (E.cellstyle.backcolor))
{
using (pen Gridlinepen = new Pen (gridbrush,2))
{
Erase the cell.
E.graphics.fillrectangle (BackColorBrush, e.cellbounds);
Crossed
Point P1 = new Point (E.cellbounds.left+e.cellbounds.width, e.cellbounds.top);
Point P2 = new Point (E.cellbounds.left+e.cellbounds.width, e.cellbounds.top+e.cellbounds.height);
Point p3 = new Point (e.cellbounds.left,e.cellbounds.top+ e.cellbounds.height);
Point[] ps = new POINT[]{P1,P2,P3};
E.graphics.drawlines (GRIDLINEPEN,PS);
Draw icon
E.graphics.drawicon (ico, newrect);
Draw a String
E.graphics.drawstring ("123", E.cellstyle.font, Brushes.crimson, E.cellbounds.left +, E.cellbounds.top, Stringformat.genericdefault);
E.handled = true;
}
}
}
}
Exceptions have other methods for reference, also in the DataGridView cellpainting event
"A" is displayed on the 1 (ie rowheader) column
if (e.rowindex >= 0 && e.columnindex = 0)
{
E.graphics.drawstring ("A", This.dataGridView1.Font, brushes.red, E.cellbounds.top + 5);
}
"A" is covered by the 1 (ie rowheader) column.
if (e.rowindex >= 0 && E.columnindex = = 1)
{
E.graphics.drawstring ("A", This.dataGridView1.Font, brushes.red, E.cellbounds.top + 5);
}
XX picture on-1 (ie rowheader) column
if (e.rowindex >= 0 && e.columnindex = 0)
{
Image img = image.fromfile (@ "f:/xx.bmp");
E.graphics.drawimage (IMG, 0, e.cellbounds.top);
}
XX picture is covered by-1 (ie rowheader) column
if (e.rowindex >= 0 && E.columnindex = = 1)
{
Image img = image.fromfile (@ "f:/xx.bmp");
E.graphics.drawimage (IMG, 0, e.cellbounds.top);
}
XX picture is covered by-1 (ie rowheader) column
if (e.rowindex >= 0 && E.columnindex = = 1)
{
Image img = image.fromfile (@ "f:/xx.bmp");
E.graphics.drawimage (IMG, e.cellbounds.left, e.cellbounds.top);
}
XX picture is covered by 0 columns
if (e.rowindex >= 0 && e.columnindex = 0)
{
Image img = image.fromfile (@ "f:/xx.bmp");
E.graphics.drawimage (IMG, e.cellbounds.left, e.cellbounds.top);
}