110,571
社区成员
发帖
与我相关
我的任务
分享
dim mLinearColor1 As Color = Color.FromArgb(248, 250, 251)
dim mLinearColor2 As Color = Color.FromArgb(196, 207, 224)
dim mGridColor As Color = Color.FromArgb(120, 147, 191) '网格线的颜色
dim mBorderColor As Color = Color.MediumBlue '控件边框的颜色
dim mMouseInColor As Color = Color.Orange '鼠标进入时控件的颜色
dim mHasFocusedColor As Color = Color.DarkCyan '控件的焦点框颜色
Private Sub MyDataGridView_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles Me.CellPainting
Dim StrFormat As New System.Drawing.StringFormat
Dim Rect As Rectangle = New Rectangle(e.CellBounds.X - 1, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height - 1)
Dim LinearGradientBrush As New Drawing2D.LinearGradientBrush(Rect, mLinearColor1, mLinearColor2, Drawing2D.LinearGradientMode.Vertical)
Try
If e.RowIndex = -1 Or e.ColumnIndex = -1 Then
e.Graphics.FillRectangle(LinearGradientBrush, Rect)
e.Graphics.DrawRectangle(New Pen(GridColor), Rect)
e.PaintContent(e.CellBounds)
e.Handled = True
End If
Catch ex As Exception
Finally
Rect = Nothing
StrFormat.Dispose()
If LinearGradientBrush IsNot Nothing Then LinearGradientBrush.Dispose()
End Try
End Sub
<asp:GridView ID="GridView1" runat="server" >
<HeaderStyle BackColor="#0000C0" Font-Bold="true" Font-Size="14px" ForeColor="red" />
</asp:GridView>