emi_sastra
asked on
ProcessCmdKey detect leave cell to process.
Hi Experts,
I have below code.
This is only works for Enter and Tab.
How could I allow leaving cell (Enter, Tab, Mouse) to process the function ?
Thank you.
I have below code.
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
If Not blnGridOnFocus Then
Return MyBase.ProcessCmdKey(msg, keyData)
End If
If keyData = Keys.Enter Or keyData = Keys.Tab Then
With dgvBarang
.EndEdit(True)
Dim dgvRow As DataGridViewRow
dgvRow = .Rows(.CurrentRow.Index)
Dim strColumnName As String = ERV_Global.Get_Column_Name_From_Datagridview(
dgvBarang,
.CurrentCell.ColumnIndex)
Select Case strColumnName
Case "HargaSatuan"
If Not IsNumeric(dgvRow.Cells("HargaSatuan").Value) Then
dgvRow.Cells("HargaSatuan").Value = 0
.Rows(.CurrentRow.Index).Cells("SatuanCode").Value = .Rows(.CurrentRow.Index).Cells("SatuanCode").Value
End If
.CurrentCell = .Rows(.CurrentRow.Index).Cells("SatuanCode")
Case "SatuanCode"
If .CurrentRow.Index < .Rows.Count - 1 Then
.CurrentCell = .Rows(.CurrentCell.RowIndex + 1).Cells("HargaSatuan")
Else
cboForGrid.Visible = False
btnSave.Focus()
Return True
End If
Case Else
SendKeys.Send("{TAB}")
.CurrentCell = .Rows(.CurrentCell.RowIndex).Cells(.CurrentCell.ColumnIndex)
End Select
.BeginEdit(True)
blnGridOnFocus = True
End With
Return True
Else
Return MyBase.ProcessCmdKey(msg, keyData)
End If
End Function
This is only works for Enter and Tab.
How could I allow leaving cell (Enter, Tab, Mouse) to process the function ?
Thank you.
What about using datagridview mouseleave event?
ASKER
- What about using datagridview mouseleave event?
And what to do ?
Thank you.
And what to do ?
Thank you.
Sorry, did you try writing the same functionality in datagridview_cellMouseLeav e event?
ASKER
-Sorry, did you try writing the same functionality in datagridview_cellMouseLeav e event?
Not yet, what should code at that event?
Thank you.
Not yet, what should code at that event?
Thank you.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.