Spread WPF 14
GrapeCity.Windows.SpreadSheet.Data Namespace / ConnectionBase Class / AddExternalConnectionType Method
The type of the external connection.

In This Topic
    AddExternalConnectionType Method
    In This Topic
    Gets the type of the external connection.
    Public Shared Sub AddExternalConnectionType( _
       ByVal type As Type _
    Dim type As Type
    public static void AddExternalConnectionType( 
       Type type


    The type of the external connection.
    This example binds to a data source.
    public class CustomConnection : GrapeCity.Windows.SpreadSheet.Data.ConnectionBase
            private string[] fields = { "Name", "Age", "Title" };
            public override string[] DataFields
                get { return this.fields; }
            public override bool CanOpen()
                return this.DataSource is Array;
            public override int GetRecordCount()
                return (this.DataSource as Array).GetLength(0);
            protected override object GetRecord(int recordIndex)
                return recordIndex;
            protected override object GetRecordValue(object record, string field)
                return (this.DataSource as Array).GetValue((int)record, Array.IndexOf(fields, field));
    private void button1_Click(object sender, RoutedEventArgs e)
                // This line of code adds the custom connection type for binding engine.
                this.gcSpreadSheet1.ActiveSheet.DataSource = new object[,]  { 
            { "Sarah", 34, "Tester" }, 
            { "Neil", 28, "Dev" }, 
            { "Tom", 41, "Manager" }, 
            { "John", 22, "Dev" }, 
            { "Perter", 20, "Tester" }, 
    Public Class CustomConnection
        Inherits GrapeCity.Windows.SpreadSheet.Data.ConnectionBase
        Private fields As String() = {"Name", "Age", "Title"}
        Public Overrides ReadOnly Property DataFields() As String()
                Return Me.fields
            End Get
        End Property
        Public Overrides Function CanOpen() As Boolean
            Return TypeOf Me.DataSource Is Array
        End Function
        Public Overrides Function GetRecordCount() As Integer
            Return TryCast(Me.DataSource, Array).GetLength(0)
        End Function
        Protected Overrides Function GetRecord(recordIndex As Integer) As Object
            Return recordIndex
        End Function
        Protected Overrides Function GetRecordValue(record As Object, field As String) As Object
            Return TryCast(Me.DataSource, Array).GetValue(CInt(record), Array.IndexOf(fields, field))
        End Function
    End Class
    Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
        ' This line of code adds the custom connection type for binding engine.
        Me.gcSpreadSheet1.ActiveSheet.DataSource = New Object(,) {{"Sarah", 34, "Tester"}, {"Neil", 28, "Dev"}, {"Tom", 41, "Manager"}, {"John", 22, "Dev"}, {"Perter", 20, "Tester"}}
    End Sub
    See Also