Visual Basic.NET - salto de campo datagridview

 
Vista:
sin imagen de perfil

salto de campo datagridview

Publicado por pepe (40 intervenciones) el 21/10/2007 22:17:48
hola alguien sabe como hacer para que cuando presiono enter no me salte al campo siguiente el datagridview? lo que pasa es que yo lo uso para que al presionar enter cargue los campos en otro formulario pero me carga los del campo siguiente porque al presionar enter se pasa a la siguiente fila. Alguien sabe como se hace? saludos.
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:salto de campo datagridview

Publicado por Huguin (3 intervenciones) el 22/10/2007 15:20:43
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
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

RE:salto de campo datagridview

Publicado por erick (1 intervención) el 28/02/2008 16:42:14
GRACIAS.. muchisisisimas gracias loco..!!!! tenia ratos de estar pariendo de como poder seleccionar una pinche celda en específico del datagrid..!!! te agradezco montones..!!
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