掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
DataGridでのTabキー押下処理を変更するには (ID:109668)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
お世話になっております。 DataGridのセルでTabキーを押下した場合に通常は右隣にフォーカスが移動するところを 次のコントロールに移動するように変更したいと思っています。 いろいろな掲示板で調べたところ http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=5675&forum=7 のような記事を発見し、その通りやってみたつもりだったのですがうまくいきませんでした。 ちなみにコンパイルはきちんと通りました。 以下に自分で書いたソースを記述します。 Public Class MyDataGrid Inherits System.Windows.Forms.DataGrid Const WM_KEYDOWN As Integer = &H100 Private mControl As Windows.Forms.Control Public Property NextControl() As Control Get Return mControl End Get Set(ByVal Value As Control) mControl = Value End Set End Property Protected Overrides Function ProcessCmdKey _ (ByRef msg As System.Windows.Forms.Message, _ ByVal keyData As System.Windows.Forms.Keys) As Boolean If msg.Msg = WM_KEYDOWN Then If (keyData = Keys.Enter) Then mControl.Focus() Return True Else Return MyBase.ProcessCmdKey(msg, keyData) End If End If 'デバック用 Debug.WriteLine("aaa") Return MyBase.ProcessCmdKey(msg, keyData) End Function Public Overrides Function PreProcessMessage(ByRef msg As Message) As Boolean If msg.Msg = WM_KEYDOWN AndAlso (msg.WParam.ToInt32() And Keys.KeyCode) = Keys.Enter Then MyBase.ProcessTabKey(True) Return True Else Return False End If End Function End Class ちなみにデバックウィンドゥにデバック用の文字aaaは表示されません。 間違いの指摘や関連情報をお寄せ頂きたいと思います。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.