Search code examples
c#.netwinformsdatagridviewdatagridviewcolumn

hide datagridview include all checkbox


I only want 1 row to display in a DataGridView, so I want to somehow hide the checkbox that appears in the column header.

This checkbox is intended to select all the checkboxes, which I don't want to allow users to do.

Image showing the checkbox I want to go away

I'm trying to avoid hiding the column headers and disguising some labels as if they were headers.

Note: I already have the code to uncheck all the other checkboxes when a user clicks on a different one.

Update: I left out that I populated the data from a data source. The "Include" column was not attached to the data source, but added from the data source wizard.


Solution

  • After some advanced experimentation (i.e. fooling around), I learned that naming a field/column "Selected" in the data source will not only cause it to be automatically included in the data grid view as a checkbox, but the header will not have a checkbox and behaves as desired.

    enter image description here

    Finagling my way to success ...