IMEがオンの状態でセル範囲を選択するとF6~F9キーでセルの編集が開始する

文書番号 : 39417     文書種別 : 不具合     登録日 : 2016/05/20     最終更新日 : 2016/12/07
文書を印刷する
対象製品
SPREAD for WPF 1.0J
状況
修正済み
詳細
IMEがオンの状態でセル範囲を選択するとF6~F9キーでセルの編集が開始します。

【手順】
1.新規ウィンドウにSPREADを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.右矢印キーを押下してB1セルに移動します
4.Shiftキーを押下しながら下矢印キーを押下してB1セルからB2セルを選択します
5.F6キーを押下します
   --セルの編集が開始します

◎サンプルコード(VB)
Public Sub New()

  ' この呼び出しはデザイナーで必要です。
  InitializeComponent()

  ' テキスト型セルのIMEモードをひらがなに設定
  Dim textCellType1 As New GrapeCity.Windows.SpreadGrid.TextCellType()
  textCellType1.IsInputMethodEnabled = True
  textCellType1.ImeConversionMode = System.Windows.Input.ImeConversionModeValues.Native Or System.Windows.Input.ImeConversionModeValues.FullShape
  textCellType1.ImeState = System.Windows.Input.InputMethodState.On
  GcSpreadGrid1.Columns(1).CellType = textCellType1

  ' テストデータの設定
  GcSpreadGrid1.Cells(0, 1).Value = "てすと"
End Sub

◎サンプルコード(C#)
public MainWindow()
{
  InitializeComponent();

  // テキスト型セルのIMEモードをひらがなに設定
  GrapeCity.Windows.SpreadGrid.TextCellType textCellType1 = new GrapeCity.Windows.SpreadGrid.TextCellType();
  textCellType1.IsInputMethodEnabled = true;
  textCellType1.ImeConversionMode = System.Windows.Input.ImeConversionModeValues.Native | System.Windows.Input.ImeConversionModeValues.FullShape;
  textCellType1.ImeState = System.Windows.Input.InputMethodState.On;
  gcSpreadGrid1.Columns[1].CellType = textCellType1;

  // テストデータの設定
  gcSpreadGrid1.Cells[0, 1].Value = "てすと";
}
回避方法
Service Pack 3(v1.0.2016.1207)で修正済みです。
Service Pack 3(v1.0.2016.1207)より前のバージョンでは次の回避方法が有効です。
------------------------------------------

SPREADが非編集状態の場合にTextBoxの選択処理を無効化します。

◎サンプルコード(VB)
Public Sub New()

  ' この呼び出しはデザイナーで必要です。
  InitializeComponent()

  ' テキスト型セルのIMEモードをひらがなに設定
  Dim textCellType1 As New GrapeCity.Windows.SpreadGrid.TextCellType()
  textCellType1.IsInputMethodEnabled = True
  textCellType1.ImeConversionMode = System.Windows.Input.ImeConversionModeValues.Native Or System.Windows.Input.ImeConversionModeValues.FullShape
  textCellType1.ImeState = System.Windows.Input.InputMethodState.On
  GcSpreadGrid1.Columns(1).CellType = textCellType1

  ' テストデータの設定
  GcSpreadGrid1.Cells(0, 1).Value = "てすと"

  [AddHandler](System.Windows.Controls.TextBox.SelectionChangedEvent, New RoutedEventHandler(AddressOf PreventSelectionChangedForNonEditState))
End Sub

Private Sub PreventSelectionChangedForNonEditState(sender As Object, e As RoutedEventArgs)
  Dim textBox = TryCast(e.OriginalSource, System.Windows.Controls.TextBox)
  If textBox IsNot Nothing AndAlso GcSpreadGrid1.EditElement Is Nothing Then ' TextBoxのイベントでSPREADが非編集状態の場合
    If textBox.SelectionLength <> 0 Then
      textBox.SelectionLength = 0
    End If
  End If
End Sub

◎サンプルコード(C#)
public MainWindow()
{
  InitializeComponent();

  // テキスト型セルのIMEモードをひらがなに設定
  GrapeCity.Windows.SpreadGrid.TextCellType textCellType1 = new GrapeCity.Windows.SpreadGrid.TextCellType();
  textCellType1.IsInputMethodEnabled = true;
  textCellType1.ImeConversionMode = System.Windows.Input.ImeConversionModeValues.Native | System.Windows.Input.ImeConversionModeValues.FullShape;
  textCellType1.ImeState = System.Windows.Input.InputMethodState.On;
  gcSpreadGrid1.Columns[1].CellType = textCellType1;

  // テストデータの設定
  gcSpreadGrid1.Cells[0, 1].Value = "てすと";

  AddHandler(System.Windows.Controls.TextBox.SelectionChangedEvent, new RoutedEventHandler(PreventSelectionChangedForNonEditState));
}

private void PreventSelectionChangedForNonEditState(object sender, RoutedEventArgs e)
{
  var textBox = e.OriginalSource as System.Windows.Controls.TextBox;
  if (textBox != null && gcSpreadGrid1.EditElement == null) // TextBoxのイベントでSPREADが非編集状態の場合
  {
    if (textBox.SelectionLength != 0)
    {
      textBox.SelectionLength = 0;
    }
  }
}