Na GRID abaixo:
DEFINE WINDOW Principal ;
AT 0,0 ;
WIDTH getdesktopwidth() * 0.8 ;
HEIGHT getdesktopheight() * 0.8 ;
TITLE '** == PACIENTES == ** == Odonto Hasse Cl¡nica Integrada Ltda == **' ;
MAIN NOMAXIMIZE ;
ON INTERACTIVECLOSE NaoSai() ; &&RELEASE FechaTudo()
ON INIT ( OpenTable() , LerDados( 1, '' ) )
*
wLin := 05
wCol := 05
wAlt := 35
wLarg := 10 * 09
wSize := 9
wIni := 14 * wSize
*
c_Browse := 'Atualizar'
c_Pesquisa := 'Pesq. Paciente'
c_Seleciona := 'Ficha Paciente'
c_NtPromis := 'QueryTest'
c_Sair := 'Sait <ESC>'
c_Versao := 'Versao'
*
@ wLin,wCol BUTTON BT1 CAPTION c_Browse ;
ACTION { LerDados( 1, '' ) } ;
WIDTH wIni ;
HEIGHT wAlt
wCol += Principal.bt1.width + 10
@ wLin,wCol BUTTON BT2 CAPTION c_Pesquisa ;
ACTION { PesqNome() } ;
WIDTH 15 * wSize ;
HEIGHT wAlt
wCol += Principal.bt2.width + 10
@ wLin,wCol BUTTON BT3 CAPTION c_Seleciona ;
ACTION { Ficha_Pac() } ;
WIDTH 15 * wSize ;
HEIGHT wAlt
wCol += Principal.bt3.width + 10
@ wLin,wCol BUTTON BT4 CAPTION c_NtPromis ;
ACTION { QueryTest() } ;
WIDTH 15 * wSize ;
HEIGHT wAlt
wCol += Principal.bt4.width + 10
@ wLin,wCol BUTTON BT5 CAPTION c_Sair ;
ACTION { FechaTudo() } ;
WIDTH 15 * wSize ;
HEIGHT wAlt
wCol += Principal.bt5.width + 10
@ wLin,wCol BUTTON BT6 CAPTION c_Versao ;
ACTION { Versao() } ;
WIDTH 15 * wSize ;
HEIGHT wAlt
*
DEFINE GRID Grid_1
ROW 80
COL 10
WIDTH nBrwWidth
HEIGHT nBrwHeight - 50
HEADERS { 'Nome', 'Identidade', 'CPF', 'Nascimento', 'Endereço', 'Bairro', 'Cidade', 'Estado', 'CEP', 'Naturalidade' }
WIDTHS { 300, 150, 200, 150, 300, 200, 200, 50, 60, 250 }
FONTNAME 'Arial'
FONTSIZE 12
ALLOWEDIT .F.
CELLNAVIGATION .T.
ONCHANGE QueryTest()
MULTISELECT .T.
END GRID
*
END WINDOW
*
Principal.Grid_1.setfocus
*
CENTER WINDOW Principal
*
ACTIVATE WINDOW Principal
*
Os dados são inseridos na GRID a partir de um ARRAY, via função abaixo:
FUNCTION RequeryShow()
*
DELETE ITEM ALL FROM Grid_1 OF Principal
*
FOR n_Conta = 1 TO Len( aRowsTB )
*
Principal.Grid_1.AddItem( { aRowsTB[n_Conta][1], aRowsTB[n_Conta][2], aRowsTB[n_Conta][3], aRowsTB[n_Conta][4], ;
aRowsTB[n_Conta][5], aRowsTB[n_Conta][6], aRowsTB[n_Conta][7], aRowsTB[n_Conta][8], ;
aRowsTB[n_Conta][9], aRowsTB[n_Conta][10] } )
*
NEXT n_Conta
*
RETURN( NIL )
Como o SetFocus está na GRID, posso "navegar" com as teclas RIGHT, LEFT, UP e DOWN.
A função abaixo deveria atualizar o valor de n_Row e n_Col, mas isto não acontece.
FUNCTION QueryTest() && Linha e Coluna atual do Grid.
*
? "This.QueryRowIndex, This.QueryColIndex" + Str ( This.QueryRowIndex ) , Str ( This.QueryColIndex )
? "This.CellRowIndex, This.CellColIndex " + Str ( This.CellRowIndex ) , Str ( This.CellColIndex )
? "This.CellRow, This.CellCol " + Str ( This.CellRow ) , Str ( This.CellCol )
? "This.CellWidth, This.CellHeight " + Str ( This.CellWidth ) , Str ( This.CellHeight )
*
Keyboard VK_RIGHT
Keyboard VK_LEFT
n_Row := This.CellRowIndex
n_Col := This.CellColIndex
IF n_Row > 0
aItemArr := Principal.Grid_1.Item ( n_Row )
? n_Row, n_Col, aItemArr[1], aItemArr[2], aItemArr[3], aItemArr[4]
ENDIF
*
Return( nil )
Como devo ler os dados da GRID na linha onde está o cursor ?
Mais ou menos como no exemplo abaixo:
n_Row := This.CellRowIndex
a_GridArray := Principal.Grid_1.Item ( n_Row )
T_Nome := a_GridArray[1]
T_RG := a_GridArray[2]
T_Cpf := a_GridArray[3]
T_Nacism := a_GridArray[4]
T_Ender := a_GridArray[5]
T_Bairro := a_GridArray[6]
T_Cidade := a_GridArray[7]
T_Est := a_GridArray[8]
T_CEP := a_GridArray[9]
T_Natural := a_GridArray[10]
Este código acima só funciona quando, depois de navegar o cursor atá na linha desejada eu uso a tecla RIGHT ou mesmo LEFT se o cursor estiver fora da coluna 1. Neste momento o valor de n_Row é atualizado corretamente.
Já fiz de tudo que os meus conhecimentos indicam, e NADA.