Data bind enum properties to grid and display description
        Posted  
        
            by TrueWill
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by TrueWill
        
        
        
        Published on 2009-10-08T20:05:51Z
        Indexed on 
            2010/04/19
            17:53 UTC
        
        
        Read the original article
        Hit count: 336
        
This is a similar question to How to bind a custom Enum description to a DataGrid, but in my case I have multiple properties.
public enum ExpectationResult
{
    [Description("-")]
    NoExpectation,
    [Description("Passed")]
    Pass,
    [Description("FAILED")]
    Fail
}
public class TestResult
{
    public string TestDescription { get; set; }
    public ExpectationResult RequiredExpectationResult { get; set; }
    public ExpectationResult NonRequiredExpectationResult { get; set; }
}
I'm binding a BindingList<TestResult> to a WinForms DataGridView (actually a DevExpress.XtraGrid.GridControl, but a generic solution would be more widely applicable). I want the descriptions to appear rather than the enum names. How can I accomplish this? (There are no constraints on the class/enum/attributes; I can change them at will.)
© Stack Overflow or respective owner