おかげさまで35年!
★―― 情報の関連性を明確にし、見えない情報を見える形に変えていく・・・
必要とする場所に最適な形で情報を提供する、それがビットのソフトウエアコンセプトです。 since 1988 ――★
Public Class frmUriage (略) ‘下の2行に見えるステートメントは1行が折り返している Private Sub frmUriage_KeyDown(ByVal sender As System.Object, ByVal e As _ System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown Try 'フォーム上で[Enter]キーが押された時の処理 If e.KeyCode = Keys.Enter Then '[Enter]キーで移動処理を行わないコントロールの処理 Dim blnThrough As Boolean = False '[Shift]キーが同時に押されていたら、逆順に移動する Dim blnForward As Boolean = e.Modifiers <> Keys.Shift 'テキストボックス(複数行入力) If TypeOf Me.ActiveControl Is TextBox _ AndAlso CType(Me.ActiveControl, TextBox).Multiline Then blnThrough = True 'コンボボックス(リストが開いた状態の場合) If TypeOf Me.ActiveControl Is ComboBox _ AndAlso CType(Me.ActiveControl, ComboBox).DroppedDown Then blnThrough = True If Not blnThrough Then 'カーソルを移動する Me.SelectNextControl(Me.ActiveControl, blnForward, True, True, True) e.Handled = True End If End If Catch ex As Exception End Try End Sub (略) End Class※この処理を実行するときは、フォームの[KeyPreview]プロパティの値を 必ずTrueにして下さい。
Public Class frmUriage (略) Private Sub frmUriage_KeyDown( _ ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown End Sub Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean 'フォーム上で[Enter]キーが押された時の前処理(プリプロセス)時の処理 Dim uKeyCode As Keys = (keyData And Keys.KeyCode) Dim uModifiers As Keys = (keyData And Keys.Modifiers) Select Case uKeyCode Case Keys.Enter '[Enter]キーで移動処理を行わないコントロールの処理 Dim blnThrough As Boolean = False '[Shift]キーが同時に押されていたら、逆順に移動する Dim blnForward As Boolean = uModifiers <> Keys.Shift 'テキストボックス(複数行入力) If TypeOf Me.ActiveControl Is TextBox _ AndAlso CType(Me.ActiveControl, TextBox).Multiline Then blnThrough = True 'コンボボックス(リストが開いた状態の場合) If TypeOf Me.ActiveControl Is ComboBox _ AndAlso CType(Me.ActiveControl, ComboBox).DroppedDown Then blnThrough = True If Not blnThrough Then 'カーソルを移動する Me.SelectNextControl(Me.ActiveControl, blnForward, True, True, True) Return True End If End Select Return MyBase.ProcessDialogKey(keyData) End Function (略) End Class前述したプリプロセスの処理とは、フォームのProcessDialogKeyメソッドで 行われる処理です。