Hi

I have 2 problems with a datagrid

problem 1
I use a datatable as datasource and I don't want the last row to be
visible (the one where you can add new rows) how can I do this?

problem 2
I use the folowing code to hide some columns to the user
dataGrid_practicegrid.TableStyles[0].GridColumnStyles[3].Width =
0;
dataGrid_practicegrid.TableStyles[0].GridColumnStyles[4].Width =
0;
and it works the first time the code is executed, but when I repress
the button that executes this code the columns becomes visible again..
I find this very strange.

Re: Datagrid problems by Bryan

Bryan
Sat Oct 28 12:37:25 CDT 2006

For problem 1, set the AllowUserToAddRows property on the DataGridView
to false.

For problem 2, are you simply trying to hide the column? If so, set the
Visible property on the DataGridViewColumn to false.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com




"daniel_westerberg_1979@hotmail.com"
<daniel_westerberg_1979@hotmail.com> wrote in message
news:1161566383.874237.85210@h48g2000cwc.googlegroups.com:

> Hi
>
> I have 2 problems with a datagrid
>
> problem 1
> I use a datatable as datasource and I don't want the last row to be
> visible (the one where you can add new rows) how can I do this?
>
> problem 2
> I use the folowing code to hide some columns to the user
> dataGrid_practicegrid.TableStyles[0].GridColumnStyles[3].Width =
> 0;
> dataGrid_practicegrid.TableStyles[0].GridColumnStyles[4].Width =
> 0;
> and it works the first time the code is executed, but when I repress
> the button that executes this code the columns becomes visible again..
> I find this very strange.


Re: Datagrid problems by D_W

D_W
Mon Oct 30 04:40:23 CST 2006

Hi Bryan

Thanks for your input,
I solved problem 2, the problem was that I was adding another
tablestyle everytime the button was pressed. I believe that if I set
AllowUserToAddRows proberty on the tablestyle instead of the datagrid
property both problems will be solved.
thanks again.

Daniel

Bryan Phillips skrev:

> For problem 1, set the AllowUserToAddRows property on the DataGridView
> to false.
>
> For problem 2, are you simply trying to hide the column? If so, set the
> Visible property on the DataGridViewColumn to false.
>
> Bryan Phillips
> MCSD, MCDBA, MCSE
> Blog: http://bphillips76.spaces.live.com
>
>
>
>
> "daniel_westerberg_1979@hotmail.com"
> <daniel_westerberg_1979@hotmail.com> wrote in message
> news:1161566383.874237.85210@h48g2000cwc.googlegroups.com:
>
> > Hi
> >
> > I have 2 problems with a datagrid
> >
> > problem 1
> > I use a datatable as datasource and I don't want the last row to be
> > visible (the one where you can add new rows) how can I do this?
> >
> > problem 2
> > I use the folowing code to hide some columns to the user
> > dataGrid_practicegrid.TableStyles[0].GridColumnStyles[3].Width =
> > 0;
> > dataGrid_practicegrid.TableStyles[0].GridColumnStyles[4].Width =
> > 0;
> > and it works the first time the code is executed, but when I repress
> > the button that executes this code the columns becomes visible again..
> > I find this very strange.