How to display checkbox for a non-bound column in a FlexGrid

Posted by: stefan on 1 June 2018, 12:24 am EST

  • Posted 1 June 2018, 12:24 am EST

    We’re using FlexGrid to display dynamic data (number and name of columns is coming in from a webservice and not Always the same).

    This used to be a Compact Framework application and there we could just set the DataType on the column to bool to make it display as a checkbox.

    In the Xamarin version however it seems the DataType is read-only, so we can’t set it.

    We tried to set the value to a boolean using ‘grd[row,col]=true’, but it does not show as a checkbox.

    How can we do this?

  • Posted 3 June 2018, 4:58 pm EST

    We found a workaround that seems to work. We created 2 helper classes to allow the grid to work databound. Class1 holds all the row data and has an indexer that returns Class2. Class2 then is a wrapper around a datafield with a BoolVal and a StrVal property.

    As our binding path we set: “[colname].StrVal” for regular columns and “[colname].BoolVal” for boolean columns. Since BoolVal returns type bool it seems the grid adusts itself correctly and uses a checkbox.

  • Posted 3 June 2018, 11:11 pm EST

    That is correct. FlexGrid, when bound to a boolean field, automatically creates a checkbox column.

Need extra support?

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

Learn More

Forum Channels