Privacidad: Recuerde que la información escrita en los foros de programación es 100% pública y que su ip será registrada asociada a su mensaje. Si encuentra un mensaje fuera de lugar, por favor, notifiquelo para su revisión y eliminación.
TIENPO PARA RELLENAR UN MSFLEXGRID
Enviado por Carmelo el día 17 de febrero de 2004
HE ESTADO VIENDO VARIOS METODOS PARA RELLENAR UN FLEXGRID, Y QUERRIA SABER CUAL ES EL MAS RAPIDO. ALGUIEN SABRIA AYUDARME A DETERMINARLO ?
¿podrías mandarme a mi también ese estudio?
Yo cargo los msflexgrid con AddItem y vbTab entre campo y campo, igual que el compañero que respondió antes.
Re: Re: Re: Re: TIENPO PARA RELLENAR UN MSFLEXGRID
Enviado por Baltasar el día 17 de febrero de 2004
Esta es una de esas cosas que me encanta hacer, porque es como "descubrir" mundos nuevos, jejeje.
Pongamos en un formulario un msflexgrid llamado GRID1, un commandbutton y cuatro textbox.
¿ya está?
vale, ahora copiamos este código dentro, pulsamos F5 y le damos al commandbutton.
Private Sub Command1_Click()
Dim tiempo
Grid1.Cols = 8
'método del additem
tiempo = Timer
Grid1.Rows = 1
For a = 0 To 29999
Grid1.AddItem "Uno" & vbKeyTab & "Dos" & vbKeyTab & "Tres" & vbKeyTab & "Cuatro" & vbKeyTab & "Cinco" & vbKeyTab & "Seis" & vbKeyTab & "Siete" & vbKeyTab & "Ocho"
Next a
Text1 = Timer - tiempo
Grid1.Rows = 1
Grid1.Clear
DoEvents
'método del textmatrix
tiempo = Timer
Grid1.Rows = 1
For a = 0 To 29999
Grid1.Rows = a + 1
Grid1.TextMatrix(a, 0) = "Uno"
Grid1.TextMatrix(a, 1) = "Dos"
Grid1.TextMatrix(a, 2) = "Tres"
Grid1.TextMatrix(a, 3) = "Cuatro"
Grid1.TextMatrix(a, 4) = "Cinco"
Grid1.TextMatrix(a, 5) = "Seis"
Grid1.TextMatrix(a, 6) = "Siete"
Grid1.TextMatrix(a, 7) = "Ocho"
Next a
Text2 = Timer - tiempo
Grid1.Rows = 1
Grid1.Clear
DoEvents
'método del textmatrix ocultando el grid
tiempo = Timer
Grid1.Visible = False
Grid1.Rows = 1
For a = 0 To 29999
Grid1.Rows = a + 1
Grid1.TextMatrix(a, 0) = "Uno"
Grid1.TextMatrix(a, 1) = "Dos"
Grid1.TextMatrix(a, 2) = "Tres"
Grid1.TextMatrix(a, 3) = "Cuatro"
Grid1.TextMatrix(a, 4) = "Cinco"
Grid1.TextMatrix(a, 5) = "Seis"
Grid1.TextMatrix(a, 6) = "Siete"
Grid1.TextMatrix(a, 7) = "Ocho"
Next a
Grid1.Visible = True
Text3 = Timer - tiempo
End Sub
lo que veremos es el tiempo que tarda en llenar el grid con un número dado de filas (30000 para este ejemplo) y nos lo irá poniendo en cada textbox según el método usado.
Alguien ve la diferencia? (sdemingo, espero pronta respuesta, porque luego hay sorpresa, y si no . . . . para qué el textbox nº 4 ???? )
Re: Re: Re: Re: Re: TIENPO PARA RELLENAR UN MSFLEXGRID
Enviado por Andres Guerrero el día 17 de febrero de 2004
Hola como VAs Baltazarte comento que lo hice y me agrado saber que del metodo en que yo hice mi proyecto cuando estudie visual es es ms rapiudo pero no se dime para que es el 4 texto????
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: TIENPO PARA RELLENAR UN MSFLEXGRID
Enviado por Baltasar el día 18 de febrero de 2004
jajajaja
pues el truco, por tonto que parezca, resulta más que efectivo, ya verás:
Private Sub Command1_Click()
Dim tiempo
Grid1.Cols = 8
'método del additem
tiempo = Timer
Grid1.Rows = 1
For a = 0 To 29999
Grid1.AddItem "Uno" & vbKeyTab & "Dos" & vbKeyTab & "Tres" & vbKeyTab & "Cuatro" & vbKeyTab & "Cinco" & vbKeyTab & "Seis" & vbKeyTab & "Siete" & vbKeyTab & "Ocho"
Next a
Text1 = Timer - tiempo
Grid1.Rows = 1
Grid1.Clear
DoEvents
'método del textmatrix
tiempo = Timer
Grid1.Rows = 1
For a = 0 To 29999
Grid1.Rows = a + 1
Grid1.TextMatrix(a, 0) = "Uno"
Grid1.TextMatrix(a, 1) = "Dos"
Grid1.TextMatrix(a, 2) = "Tres"
Grid1.TextMatrix(a, 3) = "Cuatro"
Grid1.TextMatrix(a, 4) = "Cinco"
Grid1.TextMatrix(a, 5) = "Seis"
Grid1.TextMatrix(a, 6) = "Siete"
Grid1.TextMatrix(a, 7) = "Ocho"
Next a
Text2 = Timer - tiempo
Grid1.Rows = 1
Grid1.Clear
DoEvents
'método del textmatrix ocultando el grid
tiempo = Timer
Grid1.Visible = False
Grid1.Rows = 1
For a = 0 To 29999
Grid1.Rows = a + 1
Grid1.TextMatrix(a, 0) = "Uno"
Grid1.TextMatrix(a, 1) = "Dos"
Grid1.TextMatrix(a, 2) = "Tres"
Grid1.TextMatrix(a, 3) = "Cuatro"
Grid1.TextMatrix(a, 4) = "Cinco"
Grid1.TextMatrix(a, 5) = "Seis"
Grid1.TextMatrix(a, 6) = "Siete"
Grid1.TextMatrix(a, 7) = "Ocho"
Next a
Grid1.Visible = True
Text3 = Timer - tiempo
Grid1.Rows = 1
Grid1.Clear
DoEvents
'método del textmatrix ocultando el grid, pero con sorpresa al asignar el tamaño con antelación
tiempo = Timer
Grid1.Visible = False
Grid1.Rows = 30000 ' aquí está el trucazo
For a = 0 To 29999
Grid1.TextMatrix(a, 0) = "Uno"
Grid1.TextMatrix(a, 1) = "Dos"
Grid1.TextMatrix(a, 2) = "Tres"
Grid1.TextMatrix(a, 3) = "Cuatro"
Grid1.TextMatrix(a, 4) = "Cinco"
Grid1.TextMatrix(a, 5) = "Seis"
Grid1.TextMatrix(a, 6) = "Siete"
Grid1.TextMatrix(a, 7) = "Ocho"
Next a
Grid1.Visible = True
Text4 = Timer - tiempo
End Sub
Simplemente consiste en predeterminar el tamaño del grid en lugar de ir incrementando poco a poco, parece que el hacerlo fila por fila ralentiza el proceso (cosas del visual).
En el caso de usar una base de datos para rellenarel grid, bastará con hacer un movelast y un movefirst nada más asignar el recordset para que recordcount tenga el tamaño exacto de la consulta.
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: TIENPO PARA RELLENAR UN MSFLEX
Enviado por Linkus el día 13 de enero de 2006
Ok, los objetos como Msflexgrid son OCX que se pueden usar casi igual en todos los lenguajes, solo hay que saber lo equivalente de cada uno, algo asi en VFP:
Public tiempo, vbkeytab
vbkeytab = chr(9)
thisform.Grid1.Cols = 8
*'método del additem
tiempo = thisform.Timer.interval
thisform.Grid1.Rows = 1
For a = 0 To 2999
thisform.Grid1.AddItem( "Uno" + vbKeyTab + "Dos" + vbKeyTab + "Tres" + vbKeyTab + "Cuatro" + vbKeyTab + "Cinco";
+ vbKeyTab + "Seis" + vbKeyTab + "Siete" + vbKeyTab + "Ocho")
Next a
thisform.Text1.value = thisform.Timer.interval - tiempo
thisform.Grid1.Rows = 1
thisform.Grid1.Clear
&&DoEvents
*método del textmatrix
tiempo = thisform.Timer.interval
thisform.Grid1.Rows = 1
For a = 0 To 2999
thisform.Grid1.Rows = a + 1
thisform.Grid1.TextMatrix(a, 0) = "Uno"
thisform.Grid1.TextMatrix(a, 1) = "Dos"
thisform.Grid1.TextMatrix(a, 2) = "Tres"
thisform.Grid1.TextMatrix(a, 3) = "Cuatro"
thisform.Grid1.TextMatrix(a, 4) = "Cinco"
thisform.Grid1.TextMatrix(a, 5) = "Seis"
thisform.Grid1.TextMatrix(a, 6) = "Siete"
thisform.Grid1.TextMatrix(a, 7) = "Ocho"
Next a
thisform.Text2.value = thisform.Timer.interval - tiempo
*método del textmatrix ocultando el grid
tiempo = thisform.Timer.interval
thisform.Grid1.Visible = .f.
thisform.Grid1.Rows = 1
For a = 0 To 2999
thisform.Grid1.Rows = a + 1
thisform.Grid1.TextMatrix(a, 0) = "Uno"
thisform.Grid1.TextMatrix(a, 1) = "Dos"
thisform.Grid1.TextMatrix(a, 2) = "Tres"
thisform.Grid1.TextMatrix(a, 3) = "Cuatro"
thisform.Grid1.TextMatrix(a, 4) = "Cinco"
thisform.Grid1.TextMatrix(a, 5) = "Seis"
thisform.Grid1.TextMatrix(a, 6) = "Siete"
thisform.Grid1.TextMatrix(a, 7) = "Ocho"
Next a
thisform.Grid1.Visible = .T.
thisform.Text3.value = thisform.Timer.interval - tiempo
*método del textmatrix ocultando el grid, pero con sorpresa al asignar el tamaño con antelación
tiempo = thisform.Timer.interval
thisform.Grid1.Visible = .F.
thisform.Grid1.Rows = 30000 && aquí está el trucazo
For a = 0 To 2999
thisform.Grid1.TextMatrix(a, 0) = "Uno"
thisform.Grid1.TextMatrix(a, 1) = "Dos"
thisform.Grid1.TextMatrix(a, 2) = "Tres"
thisform.Grid1.TextMatrix(a, 3) = "Cuatro"
thisform.Grid1.TextMatrix(a, 4) = "Cinco"
thisform.Grid1.TextMatrix(a, 5) = "Seis"
thisform.Grid1.TextMatrix(a, 6) = "Siete"
thisform.Grid1.TextMatrix(a, 7) = "Ocho"
Next a
thisform.Grid1.Visible = .T.
thisform.Text4.value = thisform.Timer.interval - tiempo
Solo faltó que el timer se active bien pero si rellena
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: TIENPO PARA RELLENAR UN MS
Enviado por Carlos el día 27 de agosto de 2008
Excelente ejemplo, me ha servido de mucho, lo unico que agragaria seria que si se va a utilizar en vb.net se debe cambiar el TextMatrix por Set_TextMatrix y se debe inclujir la informacion en lso parentesis.
Pero tengo un pequeño problema que no he podido resolver en .net el es numero de columnas, asignando estas por codigo. Si voya apropiedades del grid puedo poner las columnas necesarias pero por codigo "Grid1.Cols = 8" no me funciona.