Bosna i Hercegovina



#1 08.03.2018-11:53
xl_kid Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: Enter kao tab u DataGridView kako?
Pomoć prijatelja Smiling
kako da u DataGridView-u nateram ENTER da radi kao TAB. Dole je kod sa forme

podešavanja
EditMode: EditOnEnter

cod
Public Class Form1

Private Sub PorudzbineBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles PorudzbineBindingNavigatorSaveItem.Click
Try
Me.Validate()
Me.PorudzbineBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Porudzbine_DataSet)
Me.PorudzbineDetaljiTableAdapter.Update(Me.Porudzbine_DataSet)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try

End Sub

Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
Me.SelectNextControl(Me.ActiveControl, True, True, True, False) 'for Select Next Control
End If
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Porudzbine_DataSet.PorudzbineDetalji' table. You can move, or remove it, as needed.
Me.PorudzbineDetaljiTableAdapter.Fill(Me.Porudzbine_DataSet.PorudzbineDetalji)
'TODO: This line of code loads data into the 'Porudzbine_DataSet.Relacije' table. You can move, or remove it, as needed.
Me.RelacijeTableAdapter.Fill(Me.Porudzbine_DataSet.Relacije)
'TODO: This line of code loads data into the 'Porudzbine_DataSet.Kupci' table. You can move, or remove it, as needed.
Me.KupciTableAdapter.Fill(Me.Porudzbine_DataSet.Kupci)
'TODO: This line of code loads data into the 'Porudzbine_DataSet.Porudzbine' table. You can move, or remove it, as needed.
Me.PorudzbineTableAdapter.Fill(Me.Porudzbine_DataSet.Porudzbine)

End Sub

Private Sub NazivComboBox_LostFocus(sender As Object, e As EventArgs) Handles NazivComboBox.LostFocus
Dim id_dm As New Porudzbine_DataSetTableAdapters.KupciTableAdapter

Try
KupacIDTextBox.Text = id_dm.id_dm_ScalarQuery(NazivComboBox.Text)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub

Private Sub PorudzbineDetaljiDataGridView_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles PorudzbineDetaljiDataGridView.CellEndEdit

Dim naziv_proizvoda As New Porudzbine_DataSetTableAdapters.ProizvodiTableAdapter

If e.ColumnIndex = 0 Then

If Val(PorudzbineDetaljiDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then
PorudzbineDetaljiDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = naziv_proizvoda.NazivProizvoda_ScalarQuery(CInt(Val(PorudzbineDeta
ljiDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)))

End If

End If

End Sub

End Class
↑  ↓

#2 08.03.2018-14:26
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,431


Subject: Re: Enter kao tab u DataGridView kako?
Eve ti cod za ovaj problem :

na onKey_Down stavi go ova

DownloadIzvorni kod (Visual Basic):
  1. If KeyCode = vbKeyReturn Then
  2.      SendKeys "{TAB}"
  3.      'CreateObject("WScript.Shell").SendKeys "{TAB}", True
  4.  End If

Ova e za VB6 i VBA

Eve za vb Net

DownloadIzvorni kod (vb.net):
  1.  If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
  2.         SendKeys.Send("{TAB}")
  3.         e.Handled = True
  4.     End If
Ovaj komentar je mijenjan 1 puta. zadnja izmjena 08.03.2018-14:29 od strane Gjoreski. ↑  ↓

#3 08.03.2018-14:56
xl_kid Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: Re: Enter kao tab u DataGridView kako?
Neće. Nešto ne štima. I dalje posle unosa ili pregleda na prvo polje ide red ispod i tako dalje.
↑  ↓

#4 08.03.2018-17:13
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,431


Subject: Re: Enter kao tab u DataGridView kako?
gde si stavio funkcija?

Proveri dali na onKey_Down nastan kad udaris enter nesto se dogadza na primer stavi msgbox

DownloadIzvorni kod (vb.net):
  1.  If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
  2.         'SendKeys.Send("{TAB}")
  3.         MessageBox.Show("OK")
  4.         e.Handled = True
  5.     End If
↑  ↓

#5 09.03.2018-07:15
xl_kid Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: Re: Enter kao tab u DataGridView kako?
Javlja mi grešku

e.keychar is not a member of system.windows.forms.KeyEventArgs

probao sam na Private Sub PorudzbineDetaljiDataGridView_KeyPress ali se ne dešava ništa. Ide red dole umesto sledeće polje.
↑  ↓

#6 09.03.2018-09:57
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,431


Subject: Re: Enter kao tab u DataGridView kako?
Moras setirati DataGridView.EditMode kao EditOnEnter da bi radio ova :
DownloadIzvorni kod (vb.net):
  1. Private Sub dgvMyGrid_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dgvMyGrid.KeyDown
  2.     Select Case e.KeyCode
  3.         Case Keys.Enter
  4.             e.Handled = True
  5.             SendKeys.Send("{TAB}")
  6.         End Select
  7.     End Sub
↑  ↓

#7 09.03.2018-09:59
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,431


Subject: Re: Enter kao tab u DataGridView kako?
Eve uste edno resenie probaj go i ova

DownloadIzvorni kod (Visual Basic):
  1. Private Const WM_KEYDOWN = &H100
  2.  
  3. Protected Overrides Function ProcessKeyPreview(ByRef m As System.Windows.Forms.Message) As Boolean
  4. Dim keyCode As Keys = CType(m.WParam.ToInt32() And Keys.KeyCode, Keys)
  5. If m.Msg = WM_KEYDOWN And keyCode = Keys.Enter Then
  6. SendKeys.Send("{TAB}")
  7. Return True
  8. End If
  9. Return MyBase.ProcessKeyPreview(m)
  10. End Function
↑  ↓

#8 09.03.2018-10:09
xl_kid Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: Re: Enter kao tab u DataGridView kako?
Opet ide red ispod.
↑  ↓

#9 09.03.2018-10:28
xl_kid Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: Re: Enter kao tab u DataGridView kako?
Hajde da pitam... Možda ovo što radim nije ispravno. DataGridView sam stavio da mi bude kao u access subforma. U prvom polju (1) unosim šifru proizvoda u drugom (2)mi automatski izlazi naziv proizvoda (to polje bi trebalo da preskočim i fokus da stavim na sledeće polje), (3) polje je za komade, (4) transportna pakovanja i (5) težina. Polja 3, 4 i 5 su numerička i tu se unosi ili komadi ili kutije ili težina.
↑  ↓

#10 09.03.2018-10:54
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,431


Subject: Re: Enter kao tab u DataGridView kako?
Ne bi trebalo biti problema.Ja kod mene isto tako radim samo razlikaje sto ne koristim standardni grid neko imam drugi grid.
Ovaj grid koj ja ga koristim ne radi vo vb.Net.
Znam da moze ova da se resi i sa standardni gridovi,100% nesto si propustio.
Nemam ja instalirano vb.Net da mogu da probam.
↑  ↓

#11 09.03.2018-11:01
xl_kid Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: 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 Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: 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 Offline
Clan
Registrovan/a od: 11.11.2008-08:24
Komentari: 101


Subject: 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 Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,431


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

Stranice (1): 1


All times are GMT +01:00. Current time: 23.04.2018-14:09.