MindFusion WinForms Programmer's Guide
Calendar.LoadFromDataSource Method (IValueConverter)
See Also
 





Loads the schedule from the underlying data source using the specified value converter.

Namespace: MindFusion.Scheduling.WinForms
Assembly: MindFusion.Scheduling

 Syntax

C#  Copy Code

public void LoadFromDataSource (
    IValueConverter converter
)

Visual Basic  Copy Code

Public Sub LoadFromDataSource ( _
    converter As IValueConverter _
)

 Parameters

converter
The IValueConverter object providing explicit type conversion during data-binding, or null (Nothing in Visual Basic), if this object is not required.

 Remarks

Use this overload when you need to specify an explicit type conversions of values stored in the database to the destination properties.

 Example

The following example demonstrates a sample implementation of the IValueConverter interface which converts all byte values to boolean:

C#  Copy Code

public class ByteToBoolConverter : IValueConverter
{
    public object Convert(object value, object destination, string destinationMember, Type destinationType)
    {
        if (value is byte && destinationType == typeof(bool))
            return (byte)value != 0;

        return value;
    }

    public bool Supports(object value, object destination, string destinationMember, Type destinationType)
    {
        return value is byte && destinationType == typeof(bool);
    }
}

Visual Basic  Copy Code

Public Class ByteToBoolConverter
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal destination As Object, _
        ByVal destinationMember As String, ByVal destinationType As Type) As Object Implements IValueConverter.Convert

        If TypeOf value Is Byte And destinationType Is GetType(Boolean) Then
            Return CByte(value) <> 0
        End If

        Return value

    End Function

    Public Function Supports(ByVal value As Object, ByVal destination As Object, _
        ByVal destinationMember As String, ByVal destinationType As Type) As Boolean Implements IValueConverter.Supports

        Return TypeOf value Is Byte And destinationType Is GetType(Boolean)

    End Function

End Class

 See Also

LoadFromDataSource Method Overload List
Calendar Members
Calendar Class
MindFusion.Scheduling.WinForms Namespace
SaveToDataSource Method