The first column is not hidden in datagridview

I have a datagridview, and as soon as I populate the view with a data source, I hide the columns that I don't need. For some reason, the 1st column is not hidden. I checked the column name and they match, and the second row performs the column hiding perfectly for EVENTID. I even made messagebox.show (dgvTourOther.Columns ("OTHERID"). Name) and it returned the correct name.

dgvTourOther.Columns("OTHERID").Visible = False
dgvTourOther.Columns("EVENTID").Visible = False

Any idea what might cause a datagridview not to hide a column? It is like some other property is blocking this column.

The values ​​passed are all strings. I do this on 3 other datagridviews normally, but for somereason this gridview acts differently. I will try to reorder the columns and see if this helps.

+2
source share
3 answers

I remember that this problem was dedicated to the project a couple of years ago. As long as I remember. The first .Visible code was moved from the constructor (assuming you have one now) and into something like the Form_Load event.

The second solution (maybe this really worked for me) was to move the columns that I wanted to hide to the end (right) of the grid. Stupid I know.

+4
source

Whether the column name in the datagridview is the same as in the data source. This may be causing this problem.

+1
source

, Datagridview . DGV , .

            dgvProdGrp.DataSource = Nothing
    With dgvProdGrp.Columns
        .Clear()
        .Add(clsCommon.setTextColumn("prdg_id", "prdg_id", 0, 0, True, DataGridViewContentAlignment.MiddleLeft, ""))
        .Add(clsCommon.setTextColumn("prdg_name", "Group Name", 200, 1, True, DataGridViewContentAlignment.MiddleLeft, ""))
    End With
    dgvProdGrp.DataSource = objDB.View_ProdGrp(1)
0

All Articles