⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 窗体内隔行颜色.txt

📁 VB datagrid数据窗体隔行显示不同颜色,颜色可由用户自定义
💻 TXT
字号:
    '设置窗体内数据隔行显示颜色不同
Sub SetGridColor(GRID As Control, row_col As Boolean, color1 As Long, color2 As Long)
Dim i As Integer
Dim j As Integer
Dim K As Long
GRID.Redraw = False
With GRID
If row_col Then   '行间隔颜色
   For i = .FixedRows To .Rows - 1
        If K = color2 Then
           K = color1
        Else
           K = color2
        End If
           For j = .FixedCols To .Cols - 1
                .Col = j
                .Row = i
               .CellBackColor = K
           Next
        .RowHeight(i) = 280
    Next
   .Redraw = True
else
    For i = .FixedCols To .Cols - 1   '列间隔颜色
         If K = color2 Then
            K = color1 
         Else
            K = color2
         End If
     
        For j = .FixedRows To .Rows - 1
          .Col = i
          .Row = j
         .CellBackColor = K
        Next
    Next
   .Redraw = True
End If
End With
End Sub



'调用
   Call SetGridColor(grid1, True, &HD0FFE0, &HDFFFFF)  '行间隔色不同
   Call SetGridColor(grid1, flase, &HD0FFE0, &HDFFFFF)  '列间隔色不同

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -