C# DatagridView - Disable autoconversion bool values to checkbox -


i have datatable boolean columns , when use datagridview datasource, datagridview display boolean cells checkbox. possible avoid it? need string cells

thanks edit: can edit datatable if it's easier

i see 2 ways it:

  1. in datagridview set property autogeneratecolumns = false, create columns in designer or code.
    bool field use column of datagridviewtextboxcolumn type.
    datagridviewtextboxcolumn convert bool text automatically true or false

predefined columns can solution, because can control how data displayed user, , values remain in original types.

  1. convert value string in datasource changing sql query or manipulating datatable
datatable newdatatable = yourdatatable.clone(); newdatatable.columns["booltypecolumnname"].datatype = typeof(bool); foreach (datarow row in yourdatatable.rows)  {     newdatatable.importrow(row); } this.yourdatagridview.datasource = newdatatable; 

Comments