編集終了時にコンボボックス型セルに入力した文字列が消えてしまいます

文書番号 : 38915     文書種別 : 使用方法     登録日 : 2015/06/29     最終更新日 : 2015/06/29
文書を印刷する
対象製品
SPREAD for Windows Forms 8.0J
詳細
コンボボックス型セルには、データモデルに書き込まれる値を決定するEditorValueプロパティが用意されておりデフォルトはStringです。EditorValueプロパティがIndexまたはItemDataの場合、コンボボックス型セルに入力可能な文字列は、Itemsプロパティに設定したString配列のいずれかである必要があります。

仮に、コンボボックス型セルのEditableプロパティをTrueにし、キーボードによる文字列の入力を許可した場合でも、セルの編集終了後に文字列はクリアされます。Itemsプロパティに設定した配列以外の文字列を入力可能にするには、EditorValueプロパティをStringに設定する必要があります。

◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim cmbocell As New FarPoint.Win.Spread.CellType.ComboBoxCellType()
  cmbocell.Items = New String() {"Jan", "Feb", "Mar", "Apr", "May", "Jun"}
  cmbocell.ItemData = New String() {"1", "2", "3", "4", "5", "6"}
  cmbocell.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.String
  cmbocell.Editable = True
  FpSpread1.ActiveSheet.Columns(1).CellType = cmbocell
End Sub


◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
  FarPoint.Win.Spread.CellType.ComboBoxCellType cmbocell = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
  cmbocell.Items = new String[] {"Jan", "Feb", "Mar", "Apr", "May", "Jun"};
  cmbocell.ItemData = new String[] {"1", "2", "3", "4", "5", "6"};
  cmbocell.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.String;
  cmbocell.Editable = true;
  fpSpread1.ActiveSheet.Columns[1].CellType = cmbocell;
}
関連情報
キーワード
セル型