扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
text = GetText(GetColumnValueAtRow(source, rowNum))
backBrush = New SolidBrush(TextBox.BackColor)
foreBrush = New SolidBrush(TextBox.ForeColor)
ReDim Preserve BackColor(rowcollection.Count)
ReDim Preserve ForeColor(rowcollection.Count)
Dim i As Integer = 1
Do While (i <= rowcollection.Count)
If rowNum = Val(rowcollection.Item(i)) Then
If Not BackColor(i - 1).IsEmpty Then
backBrush = New SolidBrush(BackColor(i - 1))
End If
If Not ForeColor(i - 1).IsEmpty Then
foreBrush = New SolidBrush(ForeColor(i - 1))
End If
End If
i += 1
Loop
MyBase.PaintText(g, bounds, text, backBrush, foreBrush, alignToRight)
End Sub
End Class
2.关于行颜色定义的类:
Imports System.Windows.Forms
Namespace Truck_WEB
Public Class DrawDGClass
Public Class ReDrawDataDridControls : Inherits DataGridColoredTextBoxColumn
Public Sub DrawCorol(ByRef DG As DataGrid, Optional ByVal CurrentRowindex As Integer = 0)
'设置选中的行的颜色,默认是第一行选中。
Dim dt As DataTable
Dim ts As New DataGridTableStyle()
ts.AllowSorting = False
Dim aColumnTextColumn As DataGridColoredTextBoxColumn
dt = CType(DG.DataSource, DataTable)
ts.MappingName = CType(DG.DataSource, DataTable).TableName
DG.TableStyles.Clear()
Dim numCols As Integer
numCols = dt.Columns.Count
Dim i, j As Integer
i = 0
j = 0
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者