【セル型】コンボボックス型セルで折り返しを禁止したい

文書番号 : 26673     文書種別 : 使用方法     最終更新日 : 2009/01/30
文書を印刷する
対象製品
SPREAD for .NET 2.5J Web Forms Edition
詳細
コンボボックス型セルにはテキスト型セルのAllowWrap プロパティのように折り返しを禁止する機能が用意されておりませんが、以下のようにスタイルシートを使用する方法があります。

◎サンプルコード(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() {"長い文字列を設定して、", "折り返しが禁止されるか検証します"}
  cmb1.Values = New String() {"1", "2"}
  FpSpread1.ActiveSheetView.Cells(1, 0).CellType = cmb1
  FpSpread1.ActiveSheetView.Cells(1, 0).Value = "2"

  ' 折り返して表示されません
  Dim cmb2 As New FarPoint.Web.Spread.ComboBoxCellType()
  cmb2.Items = New String() {"長い文字列を設定して、", "折り返しが禁止されるか検証します"}
  cmb2.Values = New String() {"1", "2"}
  cmb2.CssClass = "CssStyle1" 'CSSクラスを設定
  FpSpread1.ActiveSheetView.Cells(1, 1).CellType = cmb2
  FpSpread1.ActiveSheetView.Cells(1, 1).Value = "2"
End Sub

-------------------------------
HTML
-------------------------------
<style type="text/css">
.CssStyle1 { white-space: pre; }
</style>

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

  // 折り返して表示されます
  FarPoint.Web.Spread.ComboBoxCellType cmb1 = new FarPoint.Web.Spread.ComboBoxCellType();
  cmb1.Items = new String[] { "長い文字列を設定して、", "折り返しが禁止されるか検証します" };
  cmb1.Values = new String[] { "1", "2" };
  FpSpread1.ActiveSheetView.Cells[1, 0].CellType = cmb1;
  FpSpread1.ActiveSheetView.Cells[1, 0].Value = "2";

  // 折り返して表示されません
  FarPoint.Web.Spread.ComboBoxCellType cmb2 = new FarPoint.Web.Spread.ComboBoxCellType();
  cmb2.Items = new String[] { "長い文字列を設定して、", "折り返しが禁止されるか検証します" };
  cmb2.Values = new String[] { "1", "2" };
  cmb2.CssClass = "CssStyle1"; 'CSSクラスを設定
  FpSpread1.ActiveSheetView.Cells[1, 1].CellType = cmb2;
  FpSpread1.ActiveSheetView.Cells[1, 1].Value = "2";
}

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

この文書は、以前は次のFAQ IDで公開されていました : 11620