New to Telerik UI for WinFormsStart a free 30-day trial

Link Type Converter

Updated over 6 months ago

When binding RadGanttView there are a number of possible formats for storing data. For most of the standard .NET types used in gantt view (int, string, DateTime, decimal) there are built-in converters to help you when binding. For the types of the link, you have to convert your data to the TasksLinkType enumeration. To help you achieve this we have provided a basic implementation to convert integer data to the enumeration. Here is the mapping:

  • 0 translates to TasksLinkType.FinishToFinish

  • 1 translates to TasksLinkType.FinishToStart

  • 2 translates to TasksLinkType.StartToFinish

  • 3 translates to TasksLinkType. StartToStart

This will work fine if your mapping is the same but if you store your link types in a different format or the integer values are in different order you can create your own LinkTypeConverter deriving from the default one. In the following examples we will create one that will convert from/to string for the following mapping:

  • “FF” translates to TasksLinkType.FinishToFinish

  • “FS” translates to TasksLinkType.FinishToStart

  • “SF” translates to TasksLinkType.StartToFinish

  • “SS” translates to TasksLinkType. StartToStart

C#
public class MyLinkTypeConverter : LinkTypeConverter
{
    public override TasksLinkType ConvertToLinkType(object value)
    {
        string stringVlaue = Convert.ToString(value);
        switch (stringVlaue)
        {
            case "FF":
                return TasksLinkType.FinishToFinish;
            case "FS":
                return TasksLinkType.FinishToStart;
            case "SF":
                return TasksLinkType.StartToFinish;
            case "SS":
                return TasksLinkType.StartToStart;
        }
        return base.ConvertToLinkType(value);
    }
    public override object ConvertFromLinkType(TasksLinkType linkType)
    {
        switch (linkType)
        {
            case TasksLinkType.FinishToFinish:
                return "FF";
            case TasksLinkType.FinishToStart:
                return "FS";
            case TasksLinkType.StartToFinish:
                return "SF";
            case TasksLinkType.StartToStart:
                return "SS";
        }
        return base.ConvertFromLinkType(linkType);
    }
}

Now to use the converter you should assign it to the LinkTypeConverter property of RadGanttView.

C#
this.radGanttView1.LinkTypeConverter = new MyLinkTypeConverter();

See Also

Not finding the help you need?
Contact Support