How do I manage the column type in the DataGridView associated with a CustomObject?
I have a DataGridView in a C # WinForms application that is a Runtime DataBound (via Form_Load) for a custom object.
In the Design View of the DataGridView, I have no columns configured.
When the Form loads the columns, they are automatically created from the data in the custom object that the DataBound belongs to.
My question is how can I manage the auto-generated columns. For example, if I want one of the columns to be a DataGridViewLinkColumn instead of the DataGridViewTextBoxColumn that is automatically generated?
source to share
By default, columns are based on data type. I have not tested, but for reference, you can try to expose the data as Indeed, if you need a specific type of column - add columns via code and set Uri
, but that might be reassuring. DataGridView.AutoGenerateColumns
to false
.
As Andrew suggests; usually something like reflection is used to create columns and you will get a column for each (viewable + public + readable) property. There is an abstraction layer if you need to, but that won't help you add a hyperlink column.
source to share