FlexGrid ValueConverter and Checkbox Column

Posted by: jim.garrison on 7 July 2025, 2:05 pm EST

    • Post Options:
    • Link

    Posted 7 July 2025, 2:05 pm EST - Updated 7 July 2025, 2:13 pm EST

    I assign a ValueConverter that returns a Boolean value to a FlexGrid GridColumn but it does not display a checkbox. It only presents True, False or blank as an editable textbox.

    Is there another way to Bind a Boolean value to a FlexGrid column so it displays a checkbox?

    /// <summary>
    /// Converts string = "-1" to true and not "-1" to false
    /// Converts back from true to "-1" and false to null
    /// </summary>
    public class StringToBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            return (string)value == "-1";
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            return (bool)value ? "-1" : null;
        }
    }
                              <c1:FlexGrid.Columns>
                                  <c1:GridColumn Binding="Remove"
                                         ValueConverter="{StaticResource StringToBoolConverter}"
                                         IsReadOnly="False"
                                         Header="Include?"
                                         Width="100"/>
  • Posted 8 July 2025, 10:03 am EST

    Hi Jim,

    The FlexGrid displays a checkbox editor only when the corresponding GridColumn is bound to a Boolean field in the ItemsSource. If the field’s data type is a string (as in your case), the grid defaults to using a TextBox as the editor.

    To display a checkbox for a string-based field, you’ll need to use a custom CellTemplate for that column. This template should have a CheckBox control, and you can bind its IsChecked property to your string field using an IValueConverter to handle the conversion.

    Please see the attached sample project for reference - CustomCheckBoxBinding.zip

    Best Regards,

    Kartik

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels