Spread Silverlight Documentation
GrapeCity.Windows.SpreadSheet.Data Namespace / Worksheet Class / DataSource Property
Example


In This Topic
    DataSource Property (Worksheet)
    In This Topic
    Gets or sets the data source that populates the sheet.
    Syntax
    'Declaration
     
    <DefaultValueAttribute("")>
    Public Property DataSource As Object
    'Usage
     
    Dim instance As Worksheet
    Dim value As Object
     
    instance.DataSource = value
     
    value = instance.DataSource
    [DefaultValue("")]
    public object DataSource {get; set;}

    Property Value

    The data source that populates the sheet.
    Example
    This example sets the DataSource property.
    public class lname
            {
                public string last { get; set; }
                public int val { get; set; }
                public lname(string last, int val)
                {
                    this.last = last;
                    this.val = val;
                }
            }
    
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                lname[] arr = new lname[] { new lname("Smith", 100), new lname("Fender", 3), new lname("Gill", 5) };
                gcSpreadSheet1.Sheets[0].DataSource = arr;
                gcSpreadSheet1.Invalidate();
             }
    Public Class lname
        Public Property last() As String
            Get
                Return m_last
            End Get
            Set
                m_last = Value
            End Set
        End Property
        Private m_last As String
        Public Property val() As Integer
            Get
                Return m_val
            End Get
            Set
                m_val = Value
            End Set
        End Property
        Private m_val As Integer
        Public Sub New(last As String, val As Integer)
            Me.last = last
            Me.val = val
        End Sub
    End Class
    
    Dim arr As lname() = New lname() {New lname("Smith", 100), New lname("Fender", 3), New lname("Gill", 5)}
    gcSpreadSheet1.Sheets(0).DataSource = arr
    gcSpreadSheet1.Invalidate()
    See Also