GrapeCity SPREAD for Windows Forms 12.0J
ClearControls メソッド


ナビゲーションツールとビュー
シートのコントロール コンテナから子コントロールをすべて削除します。
構文
public virtual void ClearControls()
'Declaration
 
Public Overridable Sub ClearControls() 
 
'使用法
 
Dim instance As SheetView
 
instance.ClearControls()
次のサンプルコードは、シートからすべての子コントロールをクリアします。
public class SpreadTextBox : TextBox, FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport {
    
    private FarPoint.Win.Spread.DrawingSpace.Moving moving = Moving.None;
    
    private FarPoint.Win.Spread.DrawingSpace.Sizing sizing = Sizing.None;
    
    private FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy activation = FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy.DoubleClick;
    
    public virtual FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy ActivationPolicy {
        get {
            return activation;
        }
        set {
            //  activation = Value
        }
    }
    
    public virtual FarPoint.Win.Spread.DrawingSpace.Moving CanMove {
        get {
            return moving;
        }
        set {
            moving = value;
        }
    }
    
    public virtual FarPoint.Win.Spread.DrawingSpace.Sizing CanSize {
        get {
            return sizing;
        }
        set {
            sizing = value;
        }
    }
    
    public void ControlPaint(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected,
bool isLocked, float zoomFactor) {
        g.SetClip(r, CombineMode.Intersect);
        g.FillRectangle(new SolidBrush(this.BackColor), r);
        // g.FillRectangle(New SolidBrush(Me.BackColor), r.X - 120, r.Y - 120, r.Width, r.Height)
        g.DrawString(this.Text, Font, new SolidBrush(this.ForeColor), r.X, r.Y);
        this.TextChanged += new System.EventHandler(this.MeTextChanged);
    }
    
    public void MeTextChanged(object sender, EventArgs e) {
        this.BackColor = Color.Beige;
    }
}

SpreadTextBox tb = new SpreadTextBox();
tb.Name = "TB";
fpSpread1.ActiveSheet.AddControl(tb, 2, 2);

    
    private void Button1Click(object sender, System.EventArgs e) {
        fpSpread1.ActiveSheet.ClearControls();
    }
Public Class SpreadTextBox
   Inherits TextBox
   Implements FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport

   Private moving As FarPoint.Win.Spread.DrawingSpace.Moving = Moving.None
   Private sizing As FarPoint.Win.Spread.DrawingSpace.Sizing = Sizing.None
   Private activation As FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy = FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy.DoubleClick

   Public Overridable Property ActivationPolicy() As FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy Implements FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport.ActivationPolicy
   Get
     Return activation
   End Get
   Set(ByVal Value As FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy)
     ' activation = Value
   End Set
   End Property

   Public Overridable Property CanMove() As FarPoint.Win.Spread.DrawingSpace.Moving Implements FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport.CanMove
       Get
           Return moving
       End Get
       Set(ByVal Value As FarPoint.Win.Spread.DrawingSpace.Moving)
          moving = Value
       End Set
   End Property

   Public Overridable Property CanSize() As FarPoint.Win.Spread.DrawingSpace.Sizing Implements FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport.CanSize
       Get
           Return sizing
       End Get
       Set(ByVal Value As FarPoint.Win.Spread.DrawingSpace.Sizing)
           sizing = Value
       End Set
   End Property


   Public Sub ControlPaint(ByVal g As Graphics, ByVal r As Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance,
ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single) Implements
FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport.ControlPaint
    g.SetClip(r, CombineMode.Intersect)
    g.FillRectangle(New SolidBrush(Me.BackColor), r)
    'g.FillRectangle(New SolidBrush(Me.BackColor), r.X - 120, r.Y - 120,r.Width, r.Height)
    g.DrawString(Me.Text, Font, New SolidBrush(Me.ForeColor), r.X, r.Y) 
    AddHandler Me.TextChanged, AddressOf MeTextChanged

  End Sub

  Public Sub MeTextChanged(ByVal sender As Object, ByVal e As EventArgs)
    Me.BackColor = Color.Beige
  End Sub
End Class

Dim tb As New SpreadTextBox()
tb.Name = "TB"
FpSpread1.ActiveSheet.AddControl(tb, 2, 2)

Private Sub Button1Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    FpSpread1.ActiveSheet.ClearControls()
End Sub
参照

SheetView クラス
SheetView メンバ

開発者ガイド

シート上の子コントロールの配置

 

 


Copyright © 2004 GrapeCity inc.