Principales respuestas
MshFlexGrid

Pregunta
-
Hola saludos a todos una consulta al momento de cargar un mshflexgrid vacío el titulo se lo pongo en el load, pero al momento de cargar solo el titulo me sale un registro vacío que al momento de llenar el formulario y agregar los items a la grilla lo hace en la segunda fila y me deja una vacía les muestro el código
Option Explicit
Private Sub btnAgregar_Click()
AddGrilla
End Sub
Private Sub btnCancelar_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rs As ADODB.Recordset
Dim Encabezado As String
lblFecha.FontBold = True
lblFecha.Caption = FormatDateTime(Date, vbLongDate)
Conectar
strSQL = "SELECT proCodigo, proDescripcion FROM Productos"
Set rs = New ADODB.Recordset
rs.Open strSQL, cnMDB, adOpenStatic, adLockOptimistic
Set dtcProducto.RowSource = rs
dtcProducto.BoundColumn = "proCodigo"
dtcProducto.ListField = "proDescripcion"
With flex
.Clear
Encabezado = "<Código|>Nombre|>Descripción|>Obs|>Precio|>Cantidad|>Total"
.FormatString = Encabezado
.Row = 0
.ColWidth(0) = 700
.ColWidth(1) = 1200
.ColWidth(2) = 2000
.ColWidth(3) = 2000
.ColWidth(4) = 900
.ColWidth(5) = 900
.ColWidth(6) = 900
End With
End Sub
Private Sub txtCedula_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And txtCedula.Text <> "" Then
mstrCedula = txtCedula.Text
MostrarDatos mstrCedula
End If
End Sub
Public Sub MostrarDatos(Cedula As String)
Dim rs As ADODB.Recordset
Dim objCliente As New clsClientes
Set rs = objCliente.GetCliente(Cedula)
txtCedula.Text = Cedula
txtIdCliente.Text = rs!cliCodigo
txtNombre.Text = rs!cliNombre
txtDireccion.Text = rs!cliDireccion
txtTelefono.Text = rs!cliTelefono
Desconectar
End Sub
Private Sub AddGrilla()
With flex
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = dtcProducto.BoundText
.TextMatrix(.Rows - 1, 1) = dtcProducto.Text
.TextMatrix(.Rows - 1, 2) = txtDescripcion.Text
.TextMatrix(.Rows - 1, 3) = txtObservacion.Text
.TextMatrix(.Rows - 1, 4) = txtPrecio.Text
.TextMatrix(.Rows - 1, 5) = txtCantidad.Text
End With
Call pvSetColors(flex, RGB(233, 233, 233), RGB(209, 222, 253))
End Sub
Pedro Avila
Respuestas
-
No tienes que ponerlo fuera, arriba de todos los sub o function
- Marcado como respuesta Pedro Ávila sábado, 16 de junio de 2012 18:38
Todas las respuestas
-
Hola
Podrias poner .Rows = .Rows + 1 despues de ingresar la fila
Private Sub AddGrilla() With flex .TextMatrix(.Rows - 1, 0) = dtcProducto.BoundText .TextMatrix(.Rows - 1, 1) = dtcProducto.Text .TextMatrix(.Rows - 1, 2) = txtDescripcion.Text .TextMatrix(.Rows - 1, 3) = txtObservacion.Text .TextMatrix(.Rows - 1, 4) = txtPrecio.Text .TextMatrix(.Rows - 1, 5) = txtCantidad.Text Call pvSetColors(flex, RGB(233, 233, 233), RGB(209, 222, 253)) .Rows = .Rows + 1 End With End Sub
-
Con la opcion anterior, siempre dejara una fila vacia abajo, si no quieres que tampoco exista esa fila puedes hacer lo siguiente:
Private LLeno As Boolean Private Sub AddGrilla() With Flex If LLeno = True Then .Rows = .Rows + 1 .TextMatrix(.Rows - 1, 0) = dtcProducto.BoundText .TextMatrix(.Rows - 1, 1) = dtcProducto.Text .TextMatrix(.Rows - 1, 2) = txtDescripcion.Text .TextMatrix(.Rows - 1, 3) = txtObservacion.Text .TextMatrix(.Rows - 1, 4) = txtPrecio.Text .TextMatrix(.Rows - 1, 5) = txtCantidad.Text End With Call pvSetColors(Flex, RGB(233, 233, 233), RGB(209, 222, 253)) LLeno = True End Sub
-
Esta bien pero chanca el primer registro no agrega mas de 1 registro lo chanca el primero
Pedro Avila
Donde pones el end if- Editado Pedro Ávila sábado, 16 de junio de 2012 18:11 consulta
-
Lo as copia todo
Private LLeno As Boolean Private Sub AddGrilla() With Flex If LLeno = True Then .Rows = .Rows + 1 .TextMatrix(.Rows - 1, 0) = dtcProducto.BoundText .TextMatrix(.Rows - 1, 1) = dtcProducto.Text .TextMatrix(.Rows - 1, 2) = txtDescripcion.Text .TextMatrix(.Rows - 1, 3) = txtObservacion.Text .TextMatrix(.Rows - 1, 4) = txtPrecio.Text .TextMatrix(.Rows - 1, 5) = txtCantidad.Text End With Call pvSetColors(Flex, RGB(233, 233, 233), RGB(209, 222, 253)) LLeno = True End Sub
As colocado la linea LLeno = true
- Editado ToniAG sábado, 16 de junio de 2012 18:19
-
si pero Private Lleno lo he puesto dentro del procedimiento asi
Private Sub AddGrilla()
Dim Lleno As Boolean
With flex
' .Rows = .Rows + 1 ==> esto esta comentado
If Lleno = True Then .Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = dtcProducto.BoundText
.TextMatrix(.Rows - 1, 1) = dtcProducto.Text
.TextMatrix(.Rows - 1, 2) = txtDescripcion.Text
.TextMatrix(.Rows - 1, 3) = txtObservacion.Text
.TextMatrix(.Rows - 1, 4) = txtPrecio.Text
.TextMatrix(.Rows - 1, 5) = txtCantidad.Text
End With
Call pvSetColors(flex, RGB(233, 233, 233), RGB(209, 222, 253))
Lleno = True
End Sub
Pedro Avila
- Editado Pedro Ávila sábado, 16 de junio de 2012 18:27 faltaba
-
No tienes que ponerlo fuera, arriba de todos los sub o function
- Marcado como respuesta Pedro Ávila sábado, 16 de junio de 2012 18:38
-
-
Otra consulta en este fragmento de código no puedo eliminar la primera fila me sale este mensaje NO SE PUEDE QUITAR LA ULTIMA FILA NO FIJA este es el código.
Private Sub btnEliminar_Click()
With flex
If .Row > 0 Then .RemoveItem (.Row)
End With
End Sub
Si puedo eliminar pero cuando queda solo un registro en la grilla ese no ese puede eliminar sale el error antes mencionado.
Pedro Avila