作成日: 2021/04/20 最終更新日: 2021/07/28
文書種別
不具合
状況
修正済み
詳細
GcRichTextBoxとフォーカス受け取り可能なコントロールがそれぞれ別のコンテナに配置されているとき、GcRichTextBoxにフォーカスを移動してからTABキーを押下しても、もう1つのコントロールにフォーカスが移動しません。
回避方法
Service Pack 6より前のバージョンでは次の方法で回避可能です。
GcShortcutコンポーネントのShortcutKeyDownイベントで明示的にフォーカス移動を行います。◎サンプルコード(VB)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GcShortcut1.ShortcutKeys.Add(Keys.Tab)
GcShortcut1.ShortcutKeys.Add(Keys.Tab Or Keys.Shift)
End Sub
Private Sub GcShortcut1_ShortcutKeyDown(sender As Object, e As KeyEventArgs) Handles GcShortcut1.ShortcutKeyDown
If Me Is Form.ActiveForm Then
If e.KeyCode = Keys.Tab Then
' アクティブコントロールの取得
Dim ac As Control = Me.ActiveControl
If ac.GetType().BaseType Is GetType(RichTextBox) Then
ac = ac.Parent
End If
' フォーカスの移動
If e.Shift Then
Me.SelectNextControl(ac, False, True, True, True)
Else
Me.SelectNextControl(ac, True, True, True, True)
End If
' 処理の終了
e.Handled = True
End If
End If
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
gcShortcut1.ShortcutKeys.Add(Keys.Tab);
gcShortcut1.ShortcutKeys.Add(Keys.Tab | Keys.Shift);
}
private void gcShortcut1_ShortcutKeyDown(object sender, KeyEventArgs e)
{
if (this == Form.ActiveForm)
{
if (e.KeyCode == Keys.Tab)
{
//アクティブコントロールの取得
Control ac = this.ActiveControl;
if ((ac.GetType().BaseType == typeof(RichTextBox)))
{
ac = ac.Parent;
}
//フォーカスの移動
if (e.Shift)
{
this.SelectNextControl(ac, false, true, true, true);
}
else
{
this.SelectNextControl(ac, true, true, true, true);
}
//処理の終了
e.Handled = true;
}
}
}