GrapeCity SPREAD for Windows Forms 11.0J サンプルコード集
セル型を設定する

単一セル/複数セル/行列全体に対してセル型(CellType)を設定することができます。セル型のクラスには様々な種類がありますが、基本的な設定手順は全て同じです。ここではコンボボックス型セル(ComboBoxCellTypeクラス)の設定を行います。

【実行例】

セル型の設定

  • シート上のデフォルトは標準型セル(GeneralCellTypeクラス)です。

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

  //ComboBoxCellTypeクラスのインスタンスを作成します
  FarPoint.Win.Spread.CellType.ComboBoxCellType cb = new FarPoint.Win.Spread.CellType.ComboBoxCellType();

  //クラスメンバの各プロパティを設定します
  cb.Items = new String[] {"aaa", "bbb", "ccc"};
  cb.ItemData = new String[] {"111", "222", "333"};
  cb.Editable = true;
  cb.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData;

  //単一セル:セル(0,0)をコンボボックス型セルとします
  fpSpread1.ActiveSheet.Cells[0, 0].CellType = cb;

  //複数セル:セル(1,1)およびセル(1,2)をコンボボックス型セルとします
  fpSpread1.ActiveSheet.Cells[1, 1, 1, 2].CellType = cb;

  //列全体:列(3)をコンボボックス型セルとします
  fpSpread1.ActiveSheet.Columns[3].CellType = cb;

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

  'ComboBoxCellTypeクラスのインスタンスを作成します
  Dim cb As New FarPoint.Win.Spread.CellType.ComboBoxCellType

  'クラスメンバの各プロパティを設定します
  cb.Items = New String() {"aaa", "bbb", "ccc"}
  cb.ItemData = New String() {"111", "222", "333"}
  cb.Editable = True
  cb.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData

  '単一セル:セル(0,0)をコンボボックス型セルとします
  FpSpread1.ActiveSheet.Cells(0, 0).CellType = cb

  '複数セル:セル(1,1)およびセル(1,2)をコンボボックス型セルとします
  FpSpread1.ActiveSheet.Cells(1, 1, 1, 2).CellType = cb

  '列全体:列(3)をコンボボックス型セルとします
  FpSpread1.ActiveSheet.Columns(3).CellType = cb

 End Sub

 

 


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