Centar za edukaciju-BiH



#11 09.03.2018 11:01
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Enter kao tab u DataGridView kako?
Probao sam i sa custom. Tu me prabaci za 2 polja desno ako ima edit polja a ako nema vrati me na prvo polje master forme. Evo cod

Public Class CustomDataGridView
Inherits DataGridView

Dim celWasEndEdit As DataGridViewCell
Private _EnterMoveNext As Boolean = True

<System.ComponentModel.DefaultValue(True)> _
Public Property OnEnterKeyMoveNext() As Boolean
Get
Return Me._EnterMoveNext
End Get
Set(ByVal value As Boolean)
Me._EnterMoveNext = value
End Set
End Property

Private Sub DataGridView_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Me.CellEndEdit
Me.celWasEndEdit = Me(e.ColumnIndex, e.RowIndex)
End Sub

Private Sub DataGridView_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SelectionChanged
' if Enter Move Next should work andalso
' mouse button was NOT down
' we are checking mouse buttons because if select was changed
' by Mouse then we will NOT do our Enter Move Next
If Me._EnterMoveNext AndAlso MouseButtons = 0 Then
' if selection is changed after Cell Editing
If Me.celWasEndEdit IsNot Nothing AndAlso _
Me.CurrentCell IsNot Nothing Then
' if we are currently in the next line of last edit cell
If Me.CurrentCell.RowIndex = Me.celWasEndEdit.RowIndex + 1 AndAlso _
Me.CurrentCell.ColumnIndex = Me.celWasEndEdit.ColumnIndex Then
Dim iColNew As Integer
Dim iRowNew As Integer
' if we at the last column
If Me.celWasEndEdit.ColumnIndex >= Me.ColumnCount - 1 Then
iColNew = 0 ' move to first column
iRowNew = Me.CurrentCell.RowIndex ' and move to next row
Else ' else it means we are NOT at the last column
' move to next column
iColNew = Me.celWasEndEdit.ColumnIndex + 1
' but row should remain same
iRowNew = Me.celWasEndEdit.RowIndex
End If
Me.CurrentCell = Me(iColNew, iRowNew) ' ok set the current column
End If
End If
Me.celWasEndEdit = Nothing ' reset the cell end edit
End If
End Sub

End Class
↑  ↓

#12 09.03.2018 11:07
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Enter kao tab u DataGridView kako?
Ovo mi sad pravi problem inače radi baz njega

Private Sub CustomDataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellEndEdit

Dim naziv_proizvoda As New Porudzbine_DataSetTableAdapters.ProizvodiTableAdapter

If e.ColumnIndex = 0 Then

If Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then
CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = naziv_proizvoda.NazivProizvoda_ScalarQuery(CInt(Val(CustomDataGrid
View1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)))

End If

End If
End Sub
↑  ↓

#13 09.03.2018 11:32
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Enter kao tab u DataGridView kako?
Uspeo sam Smiling

Public Class CustomDataGridView

Inherits DataGridView

Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean

If keyData = Keys.Enter Then

MyBase.ProcessTabKey(Keys.Tab)

Return True

End If

Return MyBase.ProcessDialogKey(keyData)

End Function

Protected Overloads Overrides Function ProcessDataGridViewKey(ByVal e As KeyEventArgs) As Boolean

If e.KeyCode = Keys.Enter Then

MyBase.ProcessTabKey(Keys.Tab)

Return True

End If

Return MyBase.ProcessDataGridViewKey(e)

End Function

End Class

Pozvao sam ovaj DGV i u proprterties EditMode promenio na EditOnEnter

Radi Smiling
↑  ↓

#14 09.03.2018 12:05
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: Enter kao tab u DataGridView kako?
Super sta si uspeo.
↑  ↓

Stranice (2):1,2


Sva vremena su GMT +01:00. Trenutno vrijeme: 12: 00 am.