GrapeCity.Xaml.SpreadSheet.UI
SetDrawingObjectProvider Method
Example 


GrapeCity.Xaml.SpreadSheet.UI Namespace > DrawingObjectManager Class : SetDrawingObjectProvider Method
A GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet
An instance of custom GrapeCity.Windows.SpreadSheet.UI.IDrawingObjectProvider
Sets the value of the GrapeCity.Windows.SpreadSheet.UI.DrawingObjectManager.IDrawingObjectProvider attached property for a given GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet control.
Syntax
'Declaration
 
Public Shared Sub SetDrawingObjectProvider( _
   ByVal element As GcSpreadSheet, _
   ByVal value As IDrawingObjectProvider _
) 
'Usage
 
Dim element As GcSpreadSheet
Dim value As IDrawingObjectProvider
 
DrawingObjectManager.SetDrawingObjectProvider(element, value)
public static void SetDrawingObjectProvider( 
   GcSpreadSheet element,
   IDrawingObjectProvider value
)

Parameters

element
A GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet
value
An instance of custom GrapeCity.Windows.SpreadSheet.UI.IDrawingObjectProvider
Example
This example uses the SetDrawingObjectProvider method.
public MainPage()
        {
            InitializeComponent();
            GrapeCity.Xaml.SpreadSheet.UI.DrawingObjectManager.SetDrawingObjectProvider(this.gcSpreadSheet1, new MyDrawingObjectProvider());
        }

        public class MyDrawingObjectProvider : GrapeCity.Xaml.SpreadSheet.UI.IDrawingObjectProvider
        {
            public GrapeCity.Xaml.SpreadSheet.Data.DrawingObject[] GetDrawingObjects(GrapeCity.Xaml.SpreadSheet.Data.Worksheet sheet, int row, int column, int rowCount, int columnCount)
            {
                if (row == 1 && column == 1)
                {
                    return new ControlDrawingObject[] { new ControlDrawingObject(row, column, new Button()) };
                }
                return sheet.GetDrawingObject(row, column, rowCount, columnCount);
            }
        }

        public class ControlDrawingObject : GrapeCity.Xaml.SpreadSheet.UI.CustomDrawingObject
        {
            private Control _rootElement;
            public ControlDrawingObject(int row, int col, Control control) : base(row, col) { _rootElement = control; this.ShowDrawingObjectOnly = true; }
            public override FrameworkElement RootElement
            {
                get { _rootElement.Margin = new Thickness(1); return _rootElement; }
            }
        }
Public Sub New()
        InitializeComponent()
        GrapeCity.Xaml.SpreadSheet.UI.DrawingObjectManager.SetDrawingObjectProvider(Me.gcSpreadSheet1, New MyDrawingObjectProvider())
    End Sub

    Public Class MyDrawingObjectProvider
        Implements GrapeCity.Xaml.SpreadSheet.UI.IDrawingObjectProvider
        Public Function GetDrawingObjects(sheet As GrapeCity.Xaml.SpreadSheet.Data.Worksheet, row As Integer, column As Integer, rowCount As Integer, columnCount As Integer) As GrapeCity.Xaml.SpreadSheet.Data.DrawingObject() Implements GrapeCity.Xaml.SpreadSheet.UI.IDrawingObjectProvider.GetDrawingObjects
            If row = 1 AndAlso column = 1 Then
                Return New ControlDrawingObject() {New ControlDrawingObject(row, column, New Button())}
            End If
            Return sheet.GetDrawingObject(row, column, rowCount, columnCount)
        End Function
    End Class

    Public Class ControlDrawingObject
        Inherits GrapeCity.Xaml.SpreadSheet.UI.CustomDrawingObject
        Private _rootElement As Control
        Public Sub New(row As Integer, col As Integer, control As Control)
            MyBase.New(row, col)
            _rootElement = control
            Me.ShowDrawingObjectOnly = True
        End Sub
        Public Overrides ReadOnly Property RootElement() As FrameworkElement
            Get
                _rootElement.Margin = New Thickness(1)
                Return _rootElement
            End Get
        End Property
    End Class
See Also

Reference

DrawingObjectManager Class
DrawingObjectManager Members