1: private void dataGridView_ArticlesMgmt_CellPainting(object sender, System.Windows.Forms.DataGridViewCellPaintingEventArgs e)
2: {
3: if (this.dataGridView_ArticlesMgmt.Columns["actionColumn"].Index ==
4: e.ColumnIndex && e.RowIndex >= 0)
5: {
6:
7: int articleCount = (int)dataGridView_ArticlesMgmt[dataGridView_ArticlesMgmt.Columns["articleCountColumn"].Index, e.RowIndex].Value;
8:
9: //If there are no articles to download, then hide the button
10: if (articleCount < 1)
11: {
12: Rectangle newRect = new Rectangle(e.CellBounds.X + 1,
13: e.CellBounds.Y + 1, e.CellBounds.Width - 4,
14: e.CellBounds.Height - 4);
15:
16: using (
17: Brush gridBrush = new SolidBrush(this.dataGridView_ArticlesMgmt.GridColor),
18: backColorBrush = new SolidBrush(e.CellStyle.BackColor))
19: {
20: using (Pen gridLinePen = new Pen(gridBrush))
21: {
22: // Erase the cell.
23: e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
24:
25: // Draw the grid lines (only the right and bottom lines;
26: // DataGridView takes care of the others).
27: e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
28: e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
29: e.CellBounds.Bottom - 1);
30: e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
31: e.CellBounds.Top, e.CellBounds.Right - 1,
32: e.CellBounds.Bottom);
33:
34: e.Handled = true;
35: }
36: }
37: }
38: }
39: }