Insertar filas y campos en datagrid
Publicado por Julián (30 intervenciones) el 12/09/2006 16:54:43
Necesito depsues de hacer una consulta y de enviarla al datagrid, adicionar unas filas en el mismo para insertar unos valores por fuera de la consulat, tengo el codgo de la funcion en visual basic 6, pero no he podido migrarla a .net!!!!
Acá dejo la función por si alguien puede ayudarme
Public Sub Totalizar_Consulta(grdConsulta As MSFlexGrid, Col1 As Integer, Nro_R As Integer)
On Error Resume Next
Dim I As Integer, TotalC As Long, ContC As Integer
If Col1 > 0 Then
For I = 1 To Nro_R
TotalC = TotalC + grdConsulta.TextMatrix(I, Col1)
Next I
ContC = Nro_R
grdConsulta.Rows = ContC + 6 'Acá
grdConsulta.Row = ContC + 2 'Acá
grdConsulta.TextMatrix(ContC + 2, 1) = "Totales:"
grdConsulta.TextMatrix(ContC + 3, 1) = "Registros:"
grdConsulta.TextMatrix(ContC + 3, 2) = ContC
grdConsulta.TextMatrix(ContC + 4, 1) = grdConsulta.TextMatrix(0, Col1)
grdConsulta.TextMatrix(ContC + 4, 2) = TotalC
For I = 1 To grdConsulta.Cols
grdConsulta.Col = I
grdConsulta.CellBackColor = vbYellow 'Sólo necesito darle fondo a la fila TOTALES
Next I
End If
End Sub
Acá dejo la función por si alguien puede ayudarme
Public Sub Totalizar_Consulta(grdConsulta As MSFlexGrid, Col1 As Integer, Nro_R As Integer)
On Error Resume Next
Dim I As Integer, TotalC As Long, ContC As Integer
If Col1 > 0 Then
For I = 1 To Nro_R
TotalC = TotalC + grdConsulta.TextMatrix(I, Col1)
Next I
ContC = Nro_R
grdConsulta.Rows = ContC + 6 'Acá
grdConsulta.Row = ContC + 2 'Acá
grdConsulta.TextMatrix(ContC + 2, 1) = "Totales:"
grdConsulta.TextMatrix(ContC + 3, 1) = "Registros:"
grdConsulta.TextMatrix(ContC + 3, 2) = ContC
grdConsulta.TextMatrix(ContC + 4, 1) = grdConsulta.TextMatrix(0, Col1)
grdConsulta.TextMatrix(ContC + 4, 2) = TotalC
For I = 1 To grdConsulta.Cols
grdConsulta.Col = I
grdConsulta.CellBackColor = vbYellow 'Sólo necesito darle fondo a la fila TOTALES
Next I
End If
End Sub
Valora esta pregunta


0