SPREAD for Windows Forms 8.0J サンプルコード集
表示値/実値のように2種類のデータを持たせる

ComboBoxCellTypeクラスのItemsプロパティおよびItemDataプロパティのそれぞれに値を設定することが可能です。また、EditorValueプロパティによって参照するセルの値の種類を指定することもできます。

【実行例】

表示イメージ

※出力例については本コンテンツ末尾を参照

 private void Form1_Load(object sender, System.EventArgs e)
 {

  FarPoint.Win.Spread.CellType.ComboBoxCellType c = new FarPoint.Win.Spread.CellType.ComboBoxCellType();

  //Itemデータ(リストに表示されるアイテム)を定義します
  c.Items = new String[] {"東京", "仙台", "大阪"};

  //ItemDateデータ(表示される各アイテムに対応したデータ)を定義します
  c.ItemData = new String[] {"001", "002", "003"};

  //セルから取得する値はItemDataとします
  c.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData;

  fpSpread1.ActiveSheet.Cells[1, 1].CellType = c;

 }

 private void button1_Click(object sender, System.EventArgs e)
 {

  Console.WriteLine("コンボボックス型セルの値は:" + fpSpread1.ActiveSheet.GetValue(1, 1));

 }
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

  Dim c As New FarPoint.Win.Spread.CellType.ComboBoxCellType

  'Itemデータ(リストに表示されるアイテム)を定義します
  c.Items = New String() {"東京", "仙台", "大阪"}

  'ItemDateデータ(表示される各アイテムに対応したデータ)を定義します
  c.ItemData = New String() {"001", "002", "003"}

  'セルから取得する値はItemDataとします
  c.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData

  FpSpread1.ActiveSheet.Cells(1, 1).CellType = c

 End Sub

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Console.WriteLine("コンボボックス型セルの値は:" + FpSpread1.ActiveSheet.GetValue(1, 1))

 End Sub

 

 


© 2004-2015, GrapeCity inc. All rights reserved.