Question : How to TRULY Hide a Column from a DataGridView?

In my application I use a DataGridView to show a DataTable.  The first field in each record in the table contains the record number of each record, however, I feel a user should not be confronted with record numbers, so I'd like to hide it.  (I need the record numbers of each row so I can manipulate the records in the database in ways I see fit.)

I tried setting the width of the corresponding column to zero but this doesn't work: even when it's set to zero, the column still appears a couple of pixels wide.  Also, since I want to allow the user to resize the columns, the user could also resize the column that contains the record number.  Which is what I don't want.

I also tried keeping two separate tables, one containing the fields I want displayed in the DataGridView, and one containing only the record numbers.  However, when the records in the DataGridView are sorted in a different order (e.g. by clicking on the column headers) then I also need to sort the table containing the corresponding record numbers, which is a fuss.

Question: is there a way to make some fields in the DataGridView invisible?  An alternative phrasing of that question is: is there are way to show only a subset of the fields of a table in a DataTable, without throwing away any columns?

Thanks in advance for your help!

Answer : How to TRULY Hide a Column from a DataGridView?

1). Within the Windows Form Designer right click on your DataGridView and select properties.
2). This will switch the view in your properties pane to the DataGridView control
3). Find the columns property and click on (Collection), this will bring up an elipsis button
4). Click on that button to open the column editing options
5). Select the column you want to hide
6). Find the property named "Visible" and set this value to false
Random Solutions  
 
programming4us programming4us