PowerTools SPREAD for Windows Forms 8.0J
PaintCell メソッド (IRenderer)


セルを描画するグラフィックインタフェース
矩形領域の位置とサイズ
セルの外観設定
オブジェクト(レンダラの名前)
セルが選択されているかどうかを表すブール値
セルがロックされているかどうか
セルを描画するときの倍率を表す数値
非編集時のセルを描画します。
構文
'Declaration
 
Sub PaintCell( _
   ByVal g As Graphics, _
   ByVal r As Rectangle, _
   ByVal appearance As Appearance, _
   ByVal value As Object, _
   ByVal isSelected As Boolean, _
   ByVal isLocked As Boolean, _
   ByVal zoomFactor As Single _
) 
'使用法
 
Dim instance As IRenderer
Dim g As Graphics
Dim r As Rectangle
Dim appearance As Appearance
Dim value As Object
Dim isSelected As Boolean
Dim isLocked As Boolean
Dim zoomFactor As Single
 
instance.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor)
void PaintCell( 
   Graphics g,
   Rectangle r,
   Appearance appearance,
   object value,
   bool isSelected,
   bool isLocked,
   float zoomFactor
)

パラメータ

g
セルを描画するグラフィックインタフェース
r
矩形領域の位置とサイズ
appearance
セルの外観設定
value
オブジェクト(レンダラの名前)
isSelected
セルが選択されているかどうかを表すブール値
isLocked
セルがロックされているかどうか
zoomFactor
セルを描画するときの倍率を表す数値
解説

zoomFactorパラメータの限度については、シートのZoomFactorプロパティを参照してください。

次のサンプルコードは、メソッドとイベントの使用方法を説明するため、IRendererクラスをサブクラス化し、スプレッドシート内の最初のセルのカスタムレンダラを作成しています。
public static CheckBox ck = new CheckBox();

class myRenderer : FarPoint.Win.Spread.CellType.IRenderer
{
  public bool CanOverflow()
  {
      return true;
  }
  public bool CanBeOverflown()
  {
      return true;
  }
  public Size GetPreferredSize(Graphics g, Size s, FarPoint.Win.Spread.Appearance appr, object value, float zoom)
 {
      s = new Size(50, 50);
      return s;
  }
  public void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appr, object value, bool issel, bool islocked,
float zoom) 
  {
      string s;
      ck.CheckState = CheckState.Checked;
      s = ck.CheckState.ToString();
      Font f = new Font("MS Sans Serif", 10);
      appr.BackColor = Color.Red;
      appr.ForeColor = Color.Yellow;
      appr.Font = f;
      Brush b, b1;
      b = new SolidBrush(appr.BackColor);
      b1 = new SolidBrush(appr.ForeColor);
      g.FillRectangle(b, r);
      g.DrawString(s, appr.Font, b1, r);
      b.Dispose();
      b1.Dispose();
      }
}

private void Form1_Load(object sender, System.EventArgs e)
{
      fpSpread1.ActiveSheet.Cells[0, 0].Renderer = new myRenderer();
}
Shared ck As New CheckBox()

Public Class myRenderer
Implements FarPoint.Win.Spread.CellType.IRenderer

Public Function CanBeOverflown() As Boolean Implements FarPoint.Win.Spread.CellType.IRenderer.CanBeOverflown
      Return True
End Function

Public Function CanOverflow() As Boolean Implements FarPoint.Win.Spread.CellType.IRenderer.CanOverflow
      Return True
End Function

Public Function GetPreferredSize(ByVal g As Graphics, ByVal s As Size, ByVal appr As FarPoint.Win.Spread.Appearance, ByVal
value As Object, ByVal zoom As Single) As Size Implements FarPoint.Win.Spread.CellType.IRenderer.GetPreferredSize
      s = New Size(50, 50)
      Return s
End Function

Public Sub PaintCell(ByVal g As Graphics, ByVal r As Rectangle, ByVal appr As FarPoint.Win.Spread.Appearance, ByVal Value
As Object, ByVal issel As Boolean, ByVal islocked As Boolean, ByVal zoom As Single) Implements FarPoint.Win.Spread.CellType.IRenderer.PaintCell
      Dim s As String
      ck.CheckState = CheckState.Checked
      s = ck.CheckState.ToString()
      Dim f As New Font("MS Sans Serif", 10)
      appr.BackColor = Color.Red
      appr.ForeColor = Color.Yellow
      appr.Font = f
      Dim b, b1 As Brush
      b = New SolidBrush(appr.BackColor)
      b1 = New SolidBrush(appr.ForeColor)
      g.FillRectangle(b, r)
      g.DrawString(s, appr.Font, b1, r.X, r.Y)
      b.Dispose()
      b1.Dispose()
End Sub

End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      FpSpread1.ActiveSheet.Cells(0, 0).Renderer = New myRenderer()
End Sub
参照

IRenderer インタフェース
IRenderer メンバ

 

 


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