【セル型】コンボボックス型セルの背景色や文字の色を変更したい

文書番号 : 37997     文書種別 : 使用方法     登録日 : 2015/02/26     最終更新日 : 2015/02/26
文書を印刷する
対象製品
SPREAD for ASP.NET 8.0J
詳細
下記サンプルコードのように、CssClassを利用することでコンボボックス型セルの背景色や文字の色を変更することができます。

◎サンプルコード(VB)
------------------------
Webフォームクラス
------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If IsPostBack Then
    Return
  End If

  Dim cmb1 As New FarPoint.Web.Spread.ComboBoxCellType()
  cmb1.Items = New String() {"Jan", "Feb", "Mar", "Apr", "May", "Jun"}
  cmb1.ShowButton = False
  cmb1.CssClass = "CssStyle1"
  FpSpread1.ActiveSheetView.Cells(1, 0).CellType = cmb1

  Dim cmb2 As New FarPoint.Web.Spread.ComboBoxCellType()
  cmb2.Items = New String() {"1月", "2月", "3月", "4月", "5月", "6月"}
  cmb2.ShowButton = True
  cmb2.CssClass = "CssStyle2"
  FpSpread1.ActiveSheetView.Cells(1, 1).CellType = cmb2
End Sub

-------------------------------
HTML
-------------------------------
<style type="text/css">
.CssStyle1 { color: #FF0000; background-color: #FFFF00 }
.CssStyle2 select{ color: #FFFFFF; background-color: #008000 }
</style>

◎サンプルコード(C#)
------------------------
Webフォームクラス
------------------------
protected void Page_Load(object sender, EventArgs e)
{
  if (Page.IsPostBack)
  {
    return;
  }

  FarPoint.Web.Spread.ComboBoxCellType cmb1 = new FarPoint.Web.Spread.ComboBoxCellType();
  cmb1.Items = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun" };
  cmb1.ShowButton = false;
  cmb1.CssClass = "CssStyle1";
  FpSpread1.ActiveSheetView.Cells[1, 0].CellType = cmb1;

  FarPoint.Web.Spread.ComboBoxCellType cmb2 = new FarPoint.Web.Spread.ComboBoxCellType();
  cmb2.Items = new String[] { "1月", "2月", "3月", "4月", "5月", "6月" };
  cmb2.ShowButton = true;
  cmb2.CssClass = "CssStyle2";
  FpSpread1.ActiveSheetView.Cells[1, 1].CellType = cmb2;
}

-------------------------------
HTML
-------------------------------
※VBと同じです
キーワード
セル型