C贸mo alimento un Grid con una matriz???
Quisiera alimentar un grid con datos que tengo en una matriz, pero sin definir el controlsource de cada columna. Simplemente como cuando se alimenta de un alias y el solo genera las columnas. Cualquier ayuda estar茅 muy agradecido
He ahi un ejemplito.
**************************************************
*-- Form: frmprueba (c:.matriz2grid.scx)
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS frmprueba AS form
Top = 0
Left = 0
Height = 294
Width = 375
DoCreate = .T.
Caption = "Matriz a Grid"
Name = "frmPrueba"
ADD OBJECT cmdsalir AS commandbutton WITH ;
Top = 245, ;
Left = 250, ;
Height = 27, ;
Width = 84, ;
Caption = "Salir", ;
Name = "cmdSalir"
ADD OBJECT grdprueba AS grid WITH ;
Height = 200, ;
Left = 10, ;
Top = 10, ;
Width = 320, ;
Name = "grdPrueba"
PROCEDURE Init
Local acMatriz
Dimension acMatriz(3,4) &&FILA X COLUMNA = REGISTROS X COLUMNA
acMatriz(1,1) = "Pepe"
acMatriz(1,2) = "Rodriguez"
acMatriz(1,3) = CtoD("05/06/79")
acMatriz(1,4) = 180
acMatriz(2,1) = "Mar铆a"
acMatriz(2,2) = "Hernandez"
acMatriz(2,3) = CtoD("20/11/77")
acMatriz(2,4) = 156
acMatriz(3,1) = "Ken"
acMatriz(3,2) = "Torrealba"
acMatriz(3,3) = CtoD("01/02/78")
acMatriz(3,4) = 169
If Used("tmp_Prueba") Then
Select tmp_Prueba
Use
EndIf
Create Cursor tmp_Prueba ;
( Nombre c(10), ;
Apellido c(10), ;
Edad d(8), ;
Estatura n(3,0) )
For i = 1 To 3
Append Blank
Replace tmp_Prueba.Nombre With acMatriz(i, 1)
Replace tmp_Prueba.Apellido With acMatriz(i, 2)
Replace tmp_Prueba.Edad With acMatriz(i, 3)
Replace tmp_Prueba.Estatura With acMatriz(i, 4)
EndFor
ThisForm.grdPrueba.RecordSource = Alias()
ENDPROC
PROCEDURE Destroy
If Used("tmp_Prueba") Then
Select tmp_Prueba
Use
EndIf
ENDPROC
PROCEDURE cmdsalir.Click
ThisForm.Release()
ENDPROC
ENDDEFINE
*
*-- EndDefine: frmprueba
**************************************************
**************************************************
*-- Form: frmprueba (c:.matriz2grid.scx)
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS frmprueba AS form
Top = 0
Left = 0
Height = 294
Width = 375
DoCreate = .T.
Caption = "Matriz a Grid"
Name = "frmPrueba"
ADD OBJECT cmdsalir AS commandbutton WITH ;
Top = 245, ;
Left = 250, ;
Height = 27, ;
Width = 84, ;
Caption = "Salir", ;
Name = "cmdSalir"
ADD OBJECT grdprueba AS grid WITH ;
Height = 200, ;
Left = 10, ;
Top = 10, ;
Width = 320, ;
Name = "grdPrueba"
PROCEDURE Init
Local acMatriz
Dimension acMatriz(3,4) &&FILA X COLUMNA = REGISTROS X COLUMNA
acMatriz(1,1) = "Pepe"
acMatriz(1,2) = "Rodriguez"
acMatriz(1,3) = CtoD("05/06/79")
acMatriz(1,4) = 180
acMatriz(2,1) = "Mar铆a"
acMatriz(2,2) = "Hernandez"
acMatriz(2,3) = CtoD("20/11/77")
acMatriz(2,4) = 156
acMatriz(3,1) = "Ken"
acMatriz(3,2) = "Torrealba"
acMatriz(3,3) = CtoD("01/02/78")
acMatriz(3,4) = 169
If Used("tmp_Prueba") Then
Select tmp_Prueba
Use
EndIf
Create Cursor tmp_Prueba ;
( Nombre c(10), ;
Apellido c(10), ;
Edad d(8), ;
Estatura n(3,0) )
For i = 1 To 3
Append Blank
Replace tmp_Prueba.Nombre With acMatriz(i, 1)
Replace tmp_Prueba.Apellido With acMatriz(i, 2)
Replace tmp_Prueba.Edad With acMatriz(i, 3)
Replace tmp_Prueba.Estatura With acMatriz(i, 4)
EndFor
ThisForm.grdPrueba.RecordSource = Alias()
ENDPROC
PROCEDURE Destroy
If Used("tmp_Prueba") Then
Select tmp_Prueba
Use
EndIf
ENDPROC
PROCEDURE cmdsalir.Click
ThisForm.Release()
ENDPROC
ENDDEFINE
*
*-- EndDefine: frmprueba
**************************************************
