'Geralmente construo a estrutura do grid no load do form
private sub form_load()
'cor da fonte
grid.ForeColor = vbBlue
'largura da celula
grid.ColWidth(0, 0) = 1000
grid.ColWidth(1, 0) = 5400
grid.ColWidth(2, 0) = 1100
grid.ColWidth(3, 0) = 1200
grid.ColWidth(4, 0) = 1300
grid.ColWidth(5, 0) = 1500
grid.ColWidth(6, 0) = 1300
grid.ColWidth(7, 0) = 1300
grid.ColWidth(8, 0) = 750
'alinhamento do texto
grid.ColAlignment(0) = flexAlignLeftCenter
grid.ColAlignment(1) = flexAlignLeftCenter
grid.ColAlignment(2) = flexAlignLeftCenter
grid.ColAlignment(3) = flexAlignRightCenter
grid.ColAlignment(4) = flexAlignRightCenter
grid.ColAlignment(5) = flexAlignRightCenter
grid.ColAlignment(6) = flexAlignRightCenter
grid.ColAlignment(7) = flexAlignRightCenter
grid.ColAlignment(8) = flexAlignLeftCenter
'cabecalho
grid.TextMatrix(0, 0) = "Código:"
grid.TextMatrix(0, 1) = "Produto:"
grid.TextMatrix(0, 2) = "Margem:"
grid.TextMatrix(0, 3) = "Desconto:"
grid.TextMatrix(0, 4) = "Custo R$:"
grid.TextMatrix(0, 5) = "Peso em Kg.:"
grid.TextMatrix(0, 6) = "Estoque:"
grid.TextMatrix(0, 7) = "Preço:"
end sub
'depois a rotina de preenchimento
private sub enchegrid()
grid.rows = 2
for i = 0 to 7
grid.textmatrix(1,i) = ""
next
if rs.eof = false then
do while not rs.eof
grid.textmatrix(grid.rows - 1,0) = rs!campo
grid.textmatrix(grid.rows - 1,1) = rs!campo
grid.textmatrix(grid.rows - 1,2) = rs!campo
grid.textmatrix(grid.rows - 1,3) = rs!campo
grid.textmatrix(grid.rows - 1,4) = rs!campo
grid.textmatrix(grid.rows - 1,5) = rs!campo
grid.textmatrix(grid.rows - 1,6) = rs!campo
grid.textmatrix(grid.rows - 1,7) = rs!campo
grid.rows = grid.rows +1
rs.movenext
loop
grid.rows = grid.rows - 1
else
msgbox "Registro não encontrado",vbinformation,"Sistema"
end if