DisplayValueFormatAttribute

For the scenarios when the provided property value is not the same as the required visualization the DisplayValueFormat attribute comes handy. This attribute provides formatting options for Date, Time and NumberPicker editor types. Here is how it can be used.

Example

Here is the decoration of the source class properties:

public class VoteResults
{
    [DisplayOptions(Header = "Votes")]
    [DisplayValueFormat(Plural = "{0} votes", Single = "{0} vote", Zero = "no votes")]
    public double Votes { get; set; }

    [DisplayOptions(Header = "Date")]
    [DisplayValueFormat(Date = "yyyy-MM-dd")]
    public DateTime Date { get; set; } = new DateTime(2016, 10, 27);
}

And here is the data form setup:

var dataForm = new RadDataForm
{
    Source = new VoteResults()
};

dataForm.RegisterEditor("Votes", EditorType.NumberPickerEditor);
dataForm.RegisterEditor("Date", EditorType.DateEditor);

See Also