DataGridView Change Cell Data Type After Binding

xster
xster
Published in
1 min readMar 22, 2010

I don’t know actually since most of the relevant stuff becomes read-only after filling with data. But my approach is solve this as early on in the process as possible to the entirety of the data and save processing time on a custom loop after.

In other words, your DataGridView is typically bound to a DataTable. That is typically filled with stuff from the database. Make sure your AutoGenerateColumns property is set to true in the DataGridView and select your data to match the type you want to display in the DataGridView. For instance, to get checkboxes,

SELECT ..., CAST(column1 AS bit), ... FROM ...

and change the data type right out of the DataAdapter and DataGridView will figure out the rest automatically

--

--