Spread Windows Forms 10.0 Product Documentation
AddControl(Control,Int32,Int32,Int32) Method
Example 


Child control being added
Index of the sheet
Index of the row to align
Index of the column to align
Adds a child control to a specified sheet at the location of the specified row and column.
Syntax
'Declaration
 
Public Overloads Overridable Function AddControl( _
   ByVal child As Control, _
   ByVal sheetIndex As Integer, _
   ByVal rowIndex As Integer, _
   ByVal columnIndex As Integer _
) As Boolean
'Usage
 
Dim instance As FpSpread
Dim child As Control
Dim sheetIndex As Integer
Dim rowIndex As Integer
Dim columnIndex As Integer
Dim value As Boolean
 
value = instance.AddControl(child, sheetIndex, rowIndex, columnIndex)
public virtual bool AddControl( 
   Control child,
   int sheetIndex,
   int rowIndex,
   int columnIndex
)

Parameters

child
Child control being added
sheetIndex
Index of the sheet
rowIndex
Index of the row to align
columnIndex
Index of the column to align

Return Value

Boolean: true if successful; false otherwise
Example
This example uses the AddControl method.
public class SpreadTextBox : TextBox, FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport
        {
            private FarPoint.Win.Spread.DrawingSpace.Moving moving = FarPoint.Win.Spread.DrawingSpace.Moving.None;
            private FarPoint.Win.Spread.DrawingSpace.Sizing sizing = FarPoint.Win.Spread.DrawingSpace.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
                {
                }
            }

            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, System.Drawing.Drawing2D.CombineMode.Intersect);
                g.FillRectangle(new SolidBrush(this.BackColor), r);
                g.DrawString(this.Text, Font, new SolidBrush(this.ForeColor), r.X, r.Y);
                this.TextChanged += new EventHandler(MeTextChanged);
            }

            public void MeTextChanged(object sender, EventArgs e)
            {
                this.BackColor = Color.Beige;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SpreadTextBox tb = new SpreadTextBox();            
            tb.Name = "TB";
            fpSpread1.AddControl(tb, 0);
            //fpSpread1.AddControl(tb, 0, 1, 1);
        }
Public Class SpreadTextBox
        Inherits TextBox
        Implements FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport

        Private moving As FarPoint.Win.Spread.DrawingSpace.Moving = FarPoint.Win.Spread.DrawingSpace.Moving.None
        Private sizing As FarPoint.Win.Spread.DrawingSpace.Sizing = FarPoint.Win.Spread.DrawingSpace.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, Drawing2D.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

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim tb As New SpreadTextBox()
        tb.Name = "TB"
        FpSpread1.AddControl(tb, 0)
        'FpSpread1.AddControl(tb, 0, 1, 1)
     End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

FpSpread Class
FpSpread Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.