It has been some time since I have used a regular datagrid on a winform
(have been using Infragistics grids instead). However, today I tried
working with a datagrid but ran into a problem. I need to make a couple of
the columns on the grid not visible. That is, the grid is mapped to a
datasource.
The material I have says all I need to do is right click on the grid and
select Property Builder, but I see no Property Builder option when right
clicking on a grid. What am I missing.
Using VS 2003.
robrich - 09 Aug 2005 18:40 GMT
Woody,
The Property Builder is part of the ASP.NET data grid, but not part of the
Windows Forms data grid. (I expect confusion like this is why the VS 2005
grid is called "DataGridView" and the ASP.NET grid has another different
name.)
In Windows Forms world, a column is controlled by a ColumnStyle associated
with a TableStyle. A TableStyle is bound to a particular table. If you're
using the grid in "just do everything for me" mode, the TableStyle and
ColumnStyles are built for you. If that's not the way you want it, ...
In the properties for the DataGrid, click on TableStyles and create a new
one. Make the MemberName the name of the table you're displaying. Then add
a ColumnStyle for each column you want to display. Want to hide it? don't
add it here. You'll then have ultimate control of the grid.
The poor man's way to do it is to set the column width to 0 after the
InitializeComponent() method is called, but this leads to some odd problems.
For example, if the user tab's through the grid, they'll land on these
"invisible" columns from time to time.
robrich