Spread Silverlight Documentation
Binding to Data

GcSpreadSheet supports binding to any object that implements the IEnumerable interface. This includes the Ilist, ObservableCollection, and WCF datasource. The control also supports binding to an RIA datasource.

GcSpreadSheet supports one way data binding. Changes to the source automatically update the target but, changes to the target are not propagated back to the source.

Specific columns can be bound with the DataField property.

Using Code

The following example binds the sheet with the DataSource property.

CS
Copy Code

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;
            }
        }

 

        //Loaded event

        {

            lname[] arr = new lname[] { new lname("Smith", 100), new lname("Fender", 3), new lname("Gill", 5) };
            gcSpreadSheet1.Sheets[0].DataSource = arr;
            gcSpreadSheet1.Invalidate();

         }

VB.NET
Copy Code

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

'Loaded event

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

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback