Advertisement
marcibang

Cell Painting

Nov 19th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. Private Sub CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs)
  2.  
  3. If e.RowIndex >= 0 Then
  4.  
  5. Dim item As cl_SetupUserAccess_SaaS.FeatureItem = sender.rows(e.RowIndex).DataBoundItem
  6.  
  7. If Not item.Name = "TrialBalance" AndAlso e.ColumnIndex = sender.columns("Add").index Then
  8.  
  9. Dim newRect As New Rectangle(e.CellBounds.X + 1, e.CellBounds.Y + 1, e.CellBounds.Width - 4, e.CellBounds.Height - 4)
  10. Dim backColorBrush As New SolidBrush(e.CellStyle.BackColor)
  11. Dim gridBrush As New SolidBrush(Color.DarkGray)
  12. Dim gridLinePen As New Pen(gridBrush)
  13.  
  14. ' Erase the cell.
  15. e.Graphics.FillRectangle(backColorBrush, e.CellBounds)
  16.  
  17. ' Draw the grid lines (only the right and bottom lines;
  18. ' DataGridView takes care of the others).
  19. e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, _
  20. e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, _
  21. e.CellBounds.Bottom - 1)
  22. 'e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, _
  23. ' e.CellBounds.Top, e.CellBounds.Right - 1, _
  24. ' e.CellBounds.Bottom)
  25.  
  26. ' Draw the inset highlight box.
  27. 'e.Graphics.DrawRectangle(New Pen(New SolidBrush(e.CellStyle.SelectionBackColor)), newRect)
  28.  
  29. e.Handled = True
  30.  
  31. End If
  32.  
  33. End If
  34.  
  35. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement