' tamanho das colunas
mshgrid_setor.ColWidth(0, 0) = 850 '************************'
mshgrid_setor.ColWidth(1, 0) = 1500 ' '
mshgrid_setor.ColWidth(2, 0) = 1500 ' Configura a flex '
mshgrid_setor.ColWidth(3, 0) = 4680
mshgrid_setor.ColAlignment(0) = flexAlignLeftCenter
mshgrid_setor.ColAlignment(1) = flexAlignLeftCenter
mshgrid_setor.ColAlignment(2) = flexAlignLeftCenter
' titulo do cabeçalho
mshgrid_setor.TextMatrix(0, 0) = "Código:" ' '
mshgrid_setor.TextMatrix(0, 1) = "Setor:" ' '
mshgrid_setor.TextMatrix(0, 2) = "Campus:" '************************'
mshgrid_setor.TextMatrix(0, 3) = "Obs.:"
' e eu coloco os dados desta forma na matriz!!!!!
rs.Open "select * from tb_setor order by cod_setor", conn, adOpenKeyset, adLockBatchOptimistic
If Not rs.BOF Then
rs.MoveMin
End If
mshgrid_setor.Rows = 2
cont = mshgrid_setor.Rows - 1
Do While Not rs.EOF
mshgrid_setor.TextMatrix(cont, 0) = Format(rs("cod_setor"), "0000")
If IsNull(rs("nome_setor")) = False Then
mshgrid_setor.TextMatrix(cont, 1) = rs("nome_setor")
End If
If IsNull(rs("campi")) = False Then
i = rs("campi")
rs_cam.Open "select * from tb_campi order by cod_campi = " & i, conn, adOpenKeyset, adLockOptimistic
If Not rs_cam.BOF Then
mshgrid_setor.TextMatrix(cont, 2) = rs_cam("campi")
End If
rs_cam.Close
End If
If IsNull(rs("obs")) = False Then
mshgrid_setor.TextMatrix(cont, 3) = rs("obs")
End If
rs.MoveNext
mshgrid_setor.Rows = mshgrid_setor.Rows + 1
cont = cont + 1
Loop
mshgrid_setor.Rows = mshgrid_setor.Rows - 1
If Not rs.BOF Then
rs.MoveMin
End If
' * fecha o recorset
rs.Close