views:

44

answers:

2

I have a datagridview and once I populate the view with the data source I hide the columns that I do not need. For some reason the 1st column is not hiding. I have checked the column name and they match and the 2nd line executes fine hides the column for the EVENTID. I even did a 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 could cause a datagridview not to hide a column? It is like some other property is locking that column..

The values being passed are all strings. I do this on 3 other datagridviews ok but for somereason this gridview is acting different. I am going to try an rearrange the columns and see if that helps.

+1  A: 

Are the name of the column in datagridview same as that which are in the datasource. This can be a reason for this problem

HotTester
+1  A: 

I remember having this issue on a project a couple years ago. There were two potential solutions as I recall. The first was moving the .Visible setting code out of the Constructor (assuming thats where you have it now) and into something like the Form_Load event.

The second solution (which may have been what really worked for me) was to move the columns I wanted to hide to the end (right side) of the grid. Stupid I know.

Nick
I rearranged the columns on the gridview and now they all hide fine now. I kept the column names the same but just rearranged them and put the two ID columns at the end.I would still like to see if their is something else going on that I am not aware of.
JPJedi
@JPJedi - Like I said... I remember this from a project a couple years ago, so the details were fuzzy. I just remember it frustrated the heck out of me, and I never felt like I found a good reason. It may just be a bug.
Nick