problemas con el MSHFlexGrid
tengo un problema con este control... resulta que utilizo el evento MshFlexGrid.AddItem " " el cual adiciona una fila mas a la tabla.. (hasta ahi bien)... pero luego que utilizo el evento MshFlexGrid.RemoveItem "" el metodo additem no funciona correctamente no adiciona filas....
haciendole un refresh agradesco si alguien me puede ayudar
haciendole un refresh agradesco si alguien me puede ayudar
soy nuevo usuario en este blog, este problema se nos ha presentado a muchos y es un dolor de cabeza además hay poca información de como resolverlo.
he creado un codigo para borrar las filas seleccionadas sin usar el mshflexgrid1.removeitem, espero que les sirva.
aqui les dejo:
Private Sub Command1_Click()
Call ELIMINAR_DATOS(mshflexgrid1)
end sub
Public Function ELIMINAR_DATOS(OBJETFLEX As MSHFlexGrid)
Dim I, J, NunfIL As Integer
NunfIL = 0
With OBJETFLEX
If .Row <= .RowSel Then
For I = .Row To .Rows - (Abs(.Row - .RowSel) + 2)
NunfIL = NunfIL + 1
For J = 0 To .Cols - 1
.TextMatrix(I, J) = ""
.TextMatrix(I, J) = .TextMatrix(.RowSel + NunfIL, J)
Next
Next
Else
For I = .RowSel To .Rows - (Abs(.Row - .RowSel) + 2)
Nunf = Nunf + 1
For J = 0 To .Cols - 1
.TextMatrix(I, J) = ""
.TextMatrix(I, J) = .TextMatrix(.Row + NunfIL, J)
Next
Next
End If
.Row = 1
End With
End Function
he creado un codigo para borrar las filas seleccionadas sin usar el mshflexgrid1.removeitem, espero que les sirva.
aqui les dejo:
Private Sub Command1_Click()
Call ELIMINAR_DATOS(mshflexgrid1)
end sub
Public Function ELIMINAR_DATOS(OBJETFLEX As MSHFlexGrid)
Dim I, J, NunfIL As Integer
NunfIL = 0
With OBJETFLEX
If .Row <= .RowSel Then
For I = .Row To .Rows - (Abs(.Row - .RowSel) + 2)
NunfIL = NunfIL + 1
For J = 0 To .Cols - 1
.TextMatrix(I, J) = ""
.TextMatrix(I, J) = .TextMatrix(.RowSel + NunfIL, J)
Next
Next
Else
For I = .RowSel To .Rows - (Abs(.Row - .RowSel) + 2)
Nunf = Nunf + 1
For J = 0 To .Cols - 1
.TextMatrix(I, J) = ""
.TextMatrix(I, J) = .TextMatrix(.Row + NunfIL, J)
Next
Next
End If
.Row = 1
End With
End Function
acuerdate que el removeitem debes utilzar el numero de la fila que deseas remover asi:
MshFlexGrid.RemoveItem (n)
donde n es el numero de fila a remover
veo que utilzas MshFlexGrid.RemoveItem ""
MshFlexGrid.RemoveItem (n)
donde n es el numero de fila a remover
veo que utilzas MshFlexGrid.RemoveItem ""
--- bueno basicamente el codigo aqui es cuando adiciono una fila a la tabla:
Private Sub cmdASERVI_Click()
Dim fila
fila = MshFlexGrid.Rows
MshFlexGrid.AddItem ""
MshFlexGrid.TextMatrix(fila, 0) = MshFlexGrid.Text
MshFlexGrid.refresh
End Sub
--- Aqui elimino la fila
Private Sub cmdESERVI_Click()
MshFlexGrid.RemoveItem (fila)
MshFlexGrid.Refresh
end sub
en verdad no se que pueda hacer... pero si alguiente una sugerencia la agradeceria..... estos son dos eventos de clic de dos comand agregar y eliminar
Private Sub cmdASERVI_Click()
Dim fila
fila = MshFlexGrid.Rows
MshFlexGrid.AddItem ""
MshFlexGrid.TextMatrix(fila, 0) = MshFlexGrid.Text
MshFlexGrid.refresh
End Sub
--- Aqui elimino la fila
Private Sub cmdESERVI_Click()
MshFlexGrid.RemoveItem (fila)
MshFlexGrid.Refresh
end sub
en verdad no se que pueda hacer... pero si alguiente una sugerencia la agradeceria..... estos son dos eventos de clic de dos comand agregar y eliminar
' has esto
Dim fila ' lo declaras en genral declarations
Private Sub cmdASERVI_Click()
fila = MshFlexGrid.Rows
MshFlexGrid.AddItem ""
MshFlexGrid.TextMatrix(fila, 0) = Str(fila)
MshFlexGrid.Refresh
End Sub
Private Sub cmdESERVI_Click()
If MshFlexGrid.Row > 1 Then ' 1 es el tamaño en fila del grid - 1, o sea MshFlexGrid.Rows - 1
MshFlexGrid.RemoveItem (fila)
MshFlexGrid.Refresh
End If
End Sub
' agregele eso en el evento click para escojer la fila que deseas eliminar ok
Private Sub MshFlexGrid_Click()
fila = MshFlexGrid.Row
End Sub
' SUERTE , ME AVISAS COMO TE SALIO
Dim fila ' lo declaras en genral declarations
Private Sub cmdASERVI_Click()
fila = MshFlexGrid.Rows
MshFlexGrid.AddItem ""
MshFlexGrid.TextMatrix(fila, 0) = Str(fila)
MshFlexGrid.Refresh
End Sub
Private Sub cmdESERVI_Click()
If MshFlexGrid.Row > 1 Then ' 1 es el tamaño en fila del grid - 1, o sea MshFlexGrid.Rows - 1
MshFlexGrid.RemoveItem (fila)
MshFlexGrid.Refresh
End If
End Sub
' agregele eso en el evento click para escojer la fila que deseas eliminar ok
Private Sub MshFlexGrid_Click()
fila = MshFlexGrid.Row
End Sub
' SUERTE , ME AVISAS COMO TE SALIO
