シートの左上(角)ヘッダに文字列を表示することは出来ますか?

文書番号 : 15892     文書種別 : 使用方法     最終更新日 : 2004/11/18
文書を印刷する
対象製品
SPREAD for .NET Windows Forms Edition
詳細
標準型セルを継承したカスタムセルクラスを作成し、PaintCellメソッドをオーバーライドしてセルの描画を独自に行います。また、左上ヘッダのスタイル情報はSheetViewクラスのSheetCornerStyleプロパティにて取得/設定することが出来ます。

◎サンプルコード(VB)
'【フォーム上の記述】
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim myCorner As New cornerCell
  myCorner.Value = "No"
  FpSpread1.ActiveSheet.SheetCornerStyle.CellType = myCorner
End Sub

'【カスタムセルクラスの記述】
Public Class cornerCell
  Inherits FarPoint.Win.Spread.CellType.GeneralCellType
  Private m_value As String

  Public Overrides Sub PaintCell(ByVal g As System.Drawing.Graphics, ByVal r As System.Drawing.Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)
    MyBase.PaintCell(g, r, appearance, m_value, isSelected, isLocked, zoomFactor)
  End Sub
  Public Property Value() As String
    Get
      Return m_value
    End Get
    Set(ByVal Value As String)
      m_value = Value
    End Set
  End Property

End Class


◎サンプルコード(C#)
//【フォーム上の記述】
private void Form1_Load(object sender, System.EventArgs e)
{
  cornerCell myCorner = new cornerCell();
  myCorner.Value = "No";
  fpSpread1.ActiveSheet.SheetCornerStyle.CellType = myCorner;
}

//【カスタムセルクラスの記述】
class cornerCell : FarPoint.Win.Spread.CellType.TextCellType
{
  private string m_value;

  public override void PaintCell(Graphics g, Rectangle r,FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
  {
    base.PaintCell(g, r, appearance, m_value, isSelected, isLocked, zoomFactor);
  }

  public string Value
  {
    get { return m_value; }
    set { m_value = value; }
  }
}
関連情報
キーワード
HowTo セル型 外観

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