例如我想把性别为男的行改为蓝色,其他的为红色...代码要怎样写???

解决方案 »

  1.   


    ListView 可以用API做一個背景圖片。
    GRID,應該可以——沒有試過
      

  2.   

    DataGrid1.Row = 0
    DataGrid1.Col = 0
    DataGrid1.BackColor = vbRed
    是不是这个?
      

  3.   

    不行啊,全变了...我那个控件名是Grid1
      

  4.   

    With Grid1
    For i = .FixedCols To .cols() - 1
    .Col = i
    .Row = .FixedRows
    .RowSel = .rows - 1
    .CellBackColor = &HC0C0C0 ' 灰色
    Next i
    End With在网上看到这段代码可以实现隔行,但我不是很明白,有谁能把他改成只要第3列的值等于男就把整行变蓝色吗/?
      

  5.   

    先定位到cell,再设置cell背景色
      

  6.   

    CellBackColor单元格的背景色你只要先定位就可以了。
      

  7.   

    Dim I as integer,J as integer,K as integer
    '循环网格
    with grid1
        for I=1 to .rows-1
            .row=i 
           '其中K代表当前的网格的性别列 
           if .textmatrix(i,K)="男"  then
               for j=1 to .cols-1
                   .col=j
                   .CellBackColor = vbBlue
               next J  
            else
               for j=1 to .cols-1
                   .col=j
                   .CellBackColor = vbRed
               next J  
            end if
        next I 
    end with