Datagrid problems

  • Thread starter daniel_westerberg_1979
  • Start date
D

daniel_westerberg_1979

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.
 
B

Bryan Phillips

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
 
D

D_W

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




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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top