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:
- in
datagridviewset propertyautogeneratecolumns = false, create columns in designer or code.
boolfield use column ofdatagridviewtextboxcolumntype.
datagridviewtextboxcolumnconvertbooltext automaticallytrueorfalse
predefined columns can solution, because can control how data displayed user, , values remain in original types.
- 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
Post a Comment