|
|
| [VS2005] DataGridViewのCell移動をEnterで |
2005/12/20 |
|
|
DataGridViewのCell移動をEnterで行えるようにします。
|
Public Class MyDataGridView
Protected Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean
If (keyData And Keys.KeyCode) = Keys.Enter Then
Return Me.ProcessRightKey(keyData)
End If
Return MyBase.ProcessDialogKey(keyData)
End Function
Protected Overrides Function ProcessDataGridViewKey(ByVal e As KeyEventArgs) As Boolean
If e.KeyCode = Keys.Enter Then
Return Me.ProcessRightKey(e.KeyData)
End If
Return MyBase.ProcessDataGridViewKey(e)
End Function
Public Shadows Function ProcessRightKey(ByVal keyData As Keys) As Boolean
If (keyData And Keys.KeyCode) = Keys.Enter Then
''最終列の場合に次の行の先頭列に移動
If MyBase.CurrentCell.ColumnIndex = MyBase.ColumnCount - 1 _
And MyBase.CurrentCell.RowIndex + 1 <= MyBase.RowCount - 1 Then
MyBase.CurrentCell = MyBase.Rows((MyBase.CurrentCell.RowIndex + 1)).Cells(0)
Return True
End If
End If
Return MyBase.ProcessRightKey(keyData)
End Function
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MyDataGridView
Inherits System.Windows.Forms.DataGridView
'UserControl はコンポーネント一覧をクリーンアップするために dispose をオーバーライドします。
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Windows フォーム デザイナで必要です。
Private components As System.ComponentModel.Icontainer
'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です。
'Windows フォーム デザイナを使用して変更できます。
'コード エディタを使って変更しないでください。
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
End Class
|
|
標準の場合でしか確認していないので、CellをComboBoxなどにしたら問題があるかも。。。
|
|