I have four dgv's on a Winform. I successfully hid the unneeded columns on the first 3 dvg's by setting their "Visible" property to false. However, there is one column that will not hide on the fourth dgv and I cannot figure out why.
Here is the code for the fourth dgv:
With Me.DataGridView4
.DataSource = BSSJ
.AutoGenerateColumns = True
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
.Columns("RecID").Visible = False
.Columns("JobID").Visible = False
.Columns("Deleted").Visible = False
.Columns("Amt").DefaultCellStyle.Format = "#,##0.00"
.Columns("Amt").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
End With
It is the "RecID" column that still appears in the dgv. The other two columns, "JobID" and "Deleted", are hidden as expected.
The data source, "BSSJ", is a bindingsource that is bound to an SQL table. I cannot omit this field from the Select statement of the query because it is needed in the relationship with the parent table.
The "RecID" is a primary key in the table bound to "BSSJ", but the other three dgv's have their primary key hidden successfully.
I'm probably missing something simple, but I just do not see it.
Any ideas?