Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
735
Format boolean column as Yes,No
posted

Hi,

I want to display a boolean column as a Yes/No string. I set the CellDisplayType to FormattedText and tried many formats: {0:Yes;No},  Yes,No,   Yes/No. I read in the online docs that "The underlying .NET formatting mechanism is used to format the value. See .NET help for more information regarding list of the named formats that are supported." So the first format should work but I just get True/False in the cell.

Thanks.

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    The article Vince is referring to here is for displaying a checkbox and storing a string, which if I understand you correctly, is exactly the opposite of what you want. You want to store a boolean, but display a string. 

    FormattedText doesn't refer to formatting the value of a cell, it refers to a custom XML format which you can use to display colors and fonts similar to RichText.

    The Format property of the column won't help you here, because the Boolean data type in DotNet doesn't accept any formats to it's ToString method.

    But there are any number of ways you can acheive what you want.

    1. You can use a ValueList. The ValueList on the column would have two items: true and false. And then you can set the DisplayText on each item to whatever you want. 
    2. You could use a DataFilter to translate the bool to a string and vice versa. 
    3. You could use a DrawFilter to draw the text yourself. 
    4. You could hide the "real" bound column and add an unbound column and populate it with a string based on the bound column. 

     

Children