RE:salto de campo datagridview
Hola Pepe.
Primero tienes que saber en que columna presioans enter.
declara tus variables fila y columna y en los eventos...
Private Sub dgvdetalle_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvdetalle.CellClick
Try
nfila = e.RowIndex : ccol = e.ColumnIndex
'MsgBox(e.ColumnIndex)
Catch ex As Exception
End Try
End Sub
Private Sub dgvdetalle_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvdetalle.CellContentClick
nfila = e.RowIndex : ccol = e.ColumnIndex
End Sub
Private Sub dgvdetalle_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvdetalle.CellValueChanged
nfila = e.RowIndex : ccol = e.ColumnIndex
End Sub
'Alli tienes la coluna y fila actual...!
en ele evento KeyUp del datagridview
Private Sub dgvdetalle_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dgvdetalle.KeyUp
Try
If nfila > -1 And ccol = 1 Then
'Sipresione enter en la columna 1 me va amostrar un formulario
If e.KeyCode = Keys.Enter Then
Dim frm As New FrmBuscarDetalleGuia(Me.cbotemporada.SelectedItem("i_nro_temporada").ToString, _
Me.cboalmacenO.SelectedItem("c_nro_almacen"), ccod_sucursal.ToString, _
ccod_empresa.ToString, Me.dgvdetalle.Rows(nfila).Cells(1).Value, nfila) '(Me.dgvdetalle.CurrentRow.Index).Cells(e.dgvdetalle + 1))
' Me.dgvdetalle.CurrentCell = Me.dgvdetalle.Rows(nfila).Cells(1 + 1)
frm.frm = Me
frm.ShowDialog()
End If
ElseIf nfila > -1 And ccol = 5 Then
'MsgBox("Paso a la siguente liena")
'si preicone enter en la columna 5
If e.KeyCode = Keys.Enter Then
' Dim frm As New FrmBuscarOrdenCompra(Me.cboproveedor.SelectedItem("c_cod_prov"), Me.dgvdetalle.Rows(nfila).Cells(1).Value, nfila) '(Me.dgvdetalle.CurrentRow.Index).Cells(e.dgvdetalle + 1))
'have una evaluacion que la cantidad que ingrese no se mayor al stok
If Me.dgvdetalle.Rows(nfila).Cells(5).Value > Me.dgvdetalle.Rows(nfila).Cells(4).Value Then
MsgBox("La Cantidad Ingresada es mayor al Stock Disponible", MsgBoxStyle.Information, "Inventarios")
Me.dgvdetalle.Rows(nfila).Cells(5).Value = 0
Me.dgvdetalle.CurrentCell = Me.dgvdetalle.Rows(nfila).Cells(5)
'Exit Sub
Else
'Me.dgvdetalle.Rows(nfila).Cells(5).Value = CDbl(Me.dgvdetalle.Rows(nfila).Cells(3).Value * Me.dgvdetalle.Rows(nfila).Cells(4).Value) '.ToString("##,#0.00")
CalculaTotales()
Me.dgvdetalle.Rows(nfila).Cells(4).Value = Integer.Parse(Me.dgvdetalle.Rows(nfila).Cells(4).Value) - Integer.Parse(Me.dgvdetalle.Rows(nfila).Cells(5).Value)
' si la cantidad ingresa es menor al stok que tengo avanza una fila
'esta lienea es la posicion en la que deve star mi cursor
Me.dgvdetalle.CurrentCell =(fila y columna a la cual quieres ir una ves presioando enter...)
Me.dgvdetalle.CurrentCell = Me.dgvdetalle.Rows(nfila + 1).Cells(ccol - 3)
End If
End If
Else
If e.KeyCode = Keys.Escape Then
If Me.dgvdetalle.Rows(nfila).Cells(0).Value Is Nothing Then
MsgBox("No Pude Quitar Una Fila Vacia", MsgBoxStyle.Information, "Inventarios")
Exit Sub
Else
Me.dgvdetalle.Rows.RemoveAt(nfila)
End If
CalculaTotales()
End If
End If
Catch ex As Exception
End Try
End Sub