Visual Basic - introducir datos a un Mshflexgrid

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

introducir datos a un Mshflexgrid

Publicado por emerson palacios (31 intervenciones) el 31/05/2005 05:49:26
no se si esto sea posible pero quisier saber si hay alguna manera de programar un mshflexgrid para que un usuario pueda ingresar datos. como en un detalle de factura por ejemplo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:introducir datos a un Mshflexgrid

Publicado por SetFocus (183 intervenciones) el 01/06/2005 06:08:05
Hola! te mando un ejemplo, para probarlo en un form agrega un msflexgrid y dos textbox sin cambiarle los nombres por defecto, luego copia el codigo que te paso en la seccion General del Form.

El ejemplo esta hecho para un msflexgrid, pero con un mshflexgrid funciona
igual.

Lo que hace esto es simular la edicion de una celda. Cuando el usuario tipea algo en la celda y si es de la columna que se puede editar(en el ejemplo las dos ultimas), utiliza los textbox para recibir lo tipiado y al presionar <enter> el valor ingresado lo graba en la celda del flex.

Bueno, lo vas a ver mejor cuando lo pruebes.Saludos

Option Explicit

Private Sub Form_Load()
' Ocultar los textbox
Text1.Visible = False
Text1.BorderStyle = 0 'None
Text2.Visible = False
Text2.BorderStyle = 0 'None
'Configurar el Grid para el ejemplo
With MSFlexGrid1
.Cols = 4
.Rows = 11
.TextMatrix(0, 2) = "Valores 1"
.TextMatrix(0, 3) = "Valores 2"
End With

End Sub

Private Sub MSFlexGrid1_GotFocus()

Text1.Visible = False
Text2.Visible = False

End Sub

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

With MSFlexGrid1
Select Case .ColSel
Case 2
Text2.Visible = False
Text1.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth - 8, .CellHeight - 8
Text1.Visible = True
If .TextMatrix(.RowSel, .ColSel) <> "" Then
Text1.Text = .TextMatrix(.RowSel, .ColSel)
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else
Text1.Text = Chr(KeyAscii)
Text1.SelStart = 1
End If
Text1.SetFocus
Case 3
Text1.Visible = False
Text2.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth - 8, .CellHeight - 8
Text2.Visible = True
If .TextMatrix(.RowSel, .ColSel) <> "" Then
Text2.Text = .TextMatrix(.RowSel, .ColSel)
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Else
Text2.Text = Chr(KeyAscii)
Text2.SelStart = 1
End If
Text2.SetFocus
End Select
End With

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then
With MSFlexGrid1
.TextMatrix(.RowSel, 2) = Text1.Text
.SetFocus
End With
KeyAscii = 0
End If

If KeyAscii = vbKeyEscape Then
MSFlexGrid1.SetFocus
KeyAscii = 0
End If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then
With MSFlexGrid1
.TextMatrix(.RowSel, 3) = Text2.Text
.SetFocus
End With
KeyAscii = 0
End If

If KeyAscii = vbKeyEscape Then
MSFlexGrid1.SetFocus
KeyAscii = 0
End If

End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar