preencho a grid assim....
Public Sub grid_prenche()
msgrid_res.Clear ' limpa a grid
cont = 0
For i = 0 To 7
msgrid_res.Col = cont
msgrid_res.Row = 0
msgrid_res.CellBackColor = &HF0AF57
msgrid_res.CellForeColor = &H80000005
msgrid_res.CellFontBold = True
msgrid_res.CellFontSize = 10
msgrid_res.CellFontName = "Comic Sans MS"
cont = cont + 1
Next
msgrid_res.ColWidth(0) = 700
msgrid_res.ColWidth(1) = 1350
msgrid_res.ColWidth(2) = 1000
msgrid_res.ColWidth(3) = 950
msgrid_res.ColWidth(4) = 3450
msgrid_res.ColWidth(5) = 900
msgrid_res.ColWidth(6) = 900
msgrid_res.ColWidth(7) = 700
msgrid_res.RowHeight(0) = 320
msgrid_res.ColAlignment(0) = flexAlignLeftCenter
msgrid_res.ColAlignment(1) = flexAlignLeftCenter
msgrid_res.TextMatrix(0, 0) = "Código"
msgrid_res.TextMatrix(0, 1) = "Reservado em:"
msgrid_res.TextMatrix(0, 2) = "Data"
msgrid_res.TextMatrix(0, 3) = "Turno"
msgrid_res.TextMatrix(0, 4) = "Professor"
msgrid_res.TextMatrix(0, 5) = "Inicio"
msgrid_res.TextMatrix(0, 6) = "Termino"
msgrid_res.TextMatrix(0, 7) = "Qdade"
If Not rs_res.BOF Then
alterna = 1 ' serve para o loop lá em baixo para colorir a grid
contador = 0 ' serve para discriminar a linha para colorir
rs_res.MoveMin
msgrid_res.Rows = 2
cont = msgrid_res.Rows - 1
msgrid_res.Rows = msgrid_res.Rows - 1
Do While Not rs_res.EOF
msgrid_res.Rows = msgrid_res.Rows + 1
If IsNull(rs_res("codigo")) = False Then
msgrid_res.TextMatrix(cont, 0) = Format(rs_res("codigo"), "0000")
Else
msgrid_res.TextMatrix(cont, 0) = "Sem Registro"
End If
If IsNull(rs_res("data_res")) = False Then
msgrid_res.TextMatrix(cont, 1) = Format(rs_res("data_res"), "dd/mm/yyyy")
Else
msgrid_res.TextMatrix(cont, 1) = "Sem Registro"
End If
If IsNull(rs_res("data")) = False Then
msgrid_res.TextMatrix(cont, 2) = Format(rs_res("data"), "dd/mm/yyyy")
Else
msgrid_res.TextMatrix(cont, 2) = "Sem Registro"
End If
If IsNull(rs_res("turno")) = False Then
msgrid_res.TextMatrix(cont, 3) = rs_res("turno")
Else
msgrid_res.TextMatrix(cont, 3) = "Sem Registro"
End If
If IsNull(rs_res("cod_prof")) = False Then
If rs_qbragalho.State = adStateOpen Then rs_qbragalho.Close
rs_qbragalho.Open "SELECT nome,codigo FROM tb_prof WHERE codigo = " & rs_res("cod_prof"), conn, adOpenKeyset, adLockOptimistic
If Not rs_qbragalho.BOF Then
msgrid_res.TextMatrix(cont, 4) = UpperCaseText(rs_qbragalho("nome"))
End If
rs_qbragalho.Close
Else
msgrid_res.TextMatrix(cont, 4) = "Sem Registro"
End If
If IsNull(rs_res("hora_ini")) = False Then
msgrid_res.TextMatrix(cont, 5) = Format(rs_res("hora_ini"), "hh:mm")
Else
msgrid_res.TextMatrix(cont, 5) = "Sem Registro"
End If
' - PAUSA PARA MUDAR A COR -------------------------
data = Time
horatest = "00:15"
data = data + horatest
If (rs_res("data") = Date) And (rs_res("hora_ini") <= data) Then
contador = 0
For i = 0 To 7
msgrid_res.Col = contador
msgrid_res.Row = cont
msgrid_res.CellBackColor = &HB1F1BB
msgrid_res.ForeColor = &H80000005
contador = contador + 1
Next
testacor = &H8080FF
Else
testacor = 0
End If
' -- FIM DA PAUSA ----------------------------------
If IsNull(rs_res("hora_fin")) = False Then
msgrid_res.TextMatrix(cont, 6) = Format(rs_res("hora_fin"), "hh:mm")
Else
msgrid_res.TextMatrix(cont, 6) = "Sem Registro"
End If
' - PAUSA PARA MUDAR A COR -------------------------
If (rs_res("data") = Date) And (rs_res("hora_fin") < Time) Then
contador = 0
For i = 0 To 7
msgrid_res.Col = contador
msgrid_res.Row = cont
msgrid_res.CellBackColor = &H8080FF
msgrid_res.ForeColor = &H80000005
contador = contador + 1
Next
testacor = &H8080FF
Else
testacor = 0
End If
' -- FIM DA PAUSA ----------------------------------
If IsNull(rs_res("qdade_micro")) = False Then
msgrid_res.TextMatrix(cont, 7) = Format(rs_res("qdade_micro"), "00")
Else
msgrid_res.TextMatrix(cont, 7) = "Sem Registro"
End If
cont = cont + 1
rs_res.MoveNext
' Exit Sub
' --- Muda a cor da linha zebrando -------------------------
'
If testacor <> &H8080FF Then
' If contador >= 2 Then
If msgrid_res.Row >= 1 Then
msgrid_res.Row = cont - 1
contador = 0
If alterna = 0 Then alterna = 1
If (alterna = 1) Or (alterna = 3) Then
For i = 0 To 7
msgrid_res.Col = contador
msgrid_res.Row = cont - 1
If i <= 1 Then
msgrid_res.CellBackColor = &HF0AF57
msgrid_res.ForeColor = &HFFFFFF
Else
msgrid_res.CellBackColor = &H80000005
msgrid_res.ForeColor = &H80000007
End If
contador = contador + 1
Next
End If ' if alterna
If (alterna = 2) Or (alterna = 4) Then
For i = 0 To 7
msgrid_res.Col = contador
msgrid_res.Row = cont - 1
If i <= 1 Then
msgrid_res.CellBackColor = &HF0AF57
msgrid_res.ForeColor = &HFFFFFF
Else
msgrid_res.CellBackColor = &HE0E0E0
msgrid_res.ForeColor = &H80000007
End If
contador = contador + 1
Next
End If ' if alterna ...
' Else
' msgrid_res.CellBackColor = &HF0AF57
' msgrid_res.ForeColor = &HFFFFFF
' End If ' if contador maior ou = 2
If alterna = 4 Then alterna = 0
If alterna = 3 Then alterna = 4
If alterna = 2 Then alterna = 3
If alterna = 1 Then alterna = 2
End If ' if linha maior ou = a 1
End If ' if testacor ...
contador = contador + 1
Loop
' cont = linha da grid
End If
If Not rs_res.BOF Then
rs_res.MoveMin
msgrid_res.Row = 1
msgrid_res.RowSel = 1
End If
End Sub
' na verdade eu ainda não fiz nada funcionar realmente, estava só fazendo testes na grid!!!
se quiseres eu posso te enviar o projeto, mas so na segunda feira!!!
Private Sub msgrid_res_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 46 Then ' se apertar zero
MsgBox "teste"
End If
End Sub
Private Sub msgrid_res_KeyPress(KeyAscii As Integer)
' If vbKeyDelete Then
' MsgBox "delete"
' End If
If KeyCode = 13 Then ' se apertar zero
MsgBox "teste no keypres"
End If
'
'
' If KeyAscii = 27 Then ' se apertar esq
' MsgBox "voce que rdeletar o registro"
' End If
End Sub
valeu meu bruxo, e o KeyPreview do form esta false valeu!!!