Friday, 9 August 2013

Setting AutoGenerateColumns property from VS 2012

Setting AutoGenerateColumns property from VS 2012

Just now I got this strange problem and I wonder if there is something I
miss in VS2012 to solve it. I'm working with MDI Windows Forms and I have
this dataGridView for which I retrieve data from database and then set the
dataSource property of the grid with the data from the database. But even
though I use an old project as a scaffold for this one, now I get my
dataGridView as designed in the VS2012 and next to it I get the data from
the database as if it's part from my dataGridView design except the header
columns are with the names of the columns from the database.
However I did a little reearch and find out that in fact this problem is
easily solved by setting AutoGenerateColumns property to false. What I
can't find is this property in the VS2012 designer. Now I'm using this :
dgvClients.AutoGenerateColumns = false;
dgvClients.DataSource = mainGridInfoList;
in the load event but I'd rather prefer to use the designer (if possible
of course) and remove this line - dgvClients.AutoGenerateColumns = false;
from my code. The problem is that I can't see property with that exact
name for the dataGridView so I wonder - is the name changed? It would be
kinda strange because I can still use it in my code, or there was never a
way to do this from the IDE designer and it must be written in the source
code explicitly?
P.S
It occurs that using the IDE designer is not very good decision for this
particular problem (at least I think so) but here is a printscreen that
can show you how to set this property from the VS2012 designer.

No comments:

Post a Comment