Resumen Textbox sobre dbgrid

Mensaje enviado por "dezalot" <dezalot@tucbbs.com.ar>

Aqui tienes un ejemplo para activar un Textbox desde un dbgrid en la misma celda que esta posicionado. En este caso se activaria en la 5ta columna. De la misma forma podrias activar lo que se te ocurra. Espero que te sirva
Saludos
Dante Dezalot


Private Sub Form_Load()
DBGrid1.Columns(5).Button = True
Text1.visible = false
end sub
Private Sub DBGrid1_BeforeColEdit(ByVal ColIndex As Integer, ByVal KeyAscii As Integer, Cancel As Integer)
If ColIndex = 5 Then
    Cancel = True
    DBGrid1_ButtonClick (5)
End If
End Sub

Private Sub DBGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    DBGrid1_ButtonClick (5)
End If
End Sub

Private Sub DBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
    DBGrid1_ButtonClick (5)
End If
End Sub

Private Sub DBGrid1_ButtonClick(ByVal ColIndex As Integer)
Dim C As Column
If ColIndex = 5 Then
    DBGrid1.AllowUpdate = True
    Set C = DBGrid1.Columns(ColIndex)
    Text1.Left = DBGrid1.Left + C.Left
    Text1.Top = DBGrid1.Top + DBGrid1.RowTop(DBGrid1.Row) ' - DBGrid1.RowHeight
    Text1.Height = DBGrid1.RowHeight
    Text1.Width = C.Width
    Text1.Text = Format(C.Value, "######0.00#")
    Text1.Visible = True
    Text1.ZOrder 0
    Text1.SetFocus
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim cTexto1 As String
If KeyAscii = 13 Then
    Data1.Recordset.Edit
    Data1.Recordset("Cantidad") = Text1.Text
    Data1.Recordset.Update
    Text1.Visible = False
    DBGrid1.AllowUpdate = False
    Exit Sub
End If
End Sub

Private Sub Text1_LostFocus()
Text1.Visible = False
DBGrid1.Refresh
DBGrid1.SetFocus
End Sub



Resumen Resumen

Visual Basic Página de Visual Basic

Página principal Página principal

www.jrubi.com