Hiding columns in a Datagrid

S

Steven Blair

Hi,

Iw ant to hide some columns in a datagrid and not sure how to go about
this.
basically, bringing back a DataSet with the following fields:

BS_Key BS_ProductId BS_ProductName

I want to display only the last 2 and hide the key.
I cant change the SQL to bring back only these fields, as I need the
key. The user will be able to double click a row and a new screen will
be displayed containing more details on the selected item, so the key is
required (the two fields are not unique to bring back further data)

Also, is it poissible to change the column names without changing the
DB? (e.g. BS_Product Id would become Product Id)

Currently, I am using a DataSet, then using each row, passing the
seperate columns into a ListView, with is powerful, but painful when
changes are required.

Any help on this is appreciated,

Steven


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Arne Janning

Steven said:
Hi,

Iw ant to hide some columns in a datagrid and not sure how to go about
this.
basically, bringing back a DataSet with the following fields:

BS_Key BS_ProductId BS_ProductName

I want to display only the last 2 and hide the key.
I cant change the SQL to bring back only these fields, as I need the
key. The user will be able to double click a row and a new screen will
be displayed containing more details on the selected item, so the key is
required (the two fields are not unique to bring back further data)

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q708q


Also, is it poissible to change the column names without changing the
DB? (e.g. BS_Product Id would become Product Id)

Have a look at DataTable.DataColumn.Caption

Cheers

Arne Janning
 
S

Steven Blair

Thanks for that, most helpful.

The following code does not seem to work though:

ds.Tables[0].Columns["BSHost_Key"].Caption = "Host Id";

If I return the value, it has "Host Id" but when displayed in the
DataGrid, it is using the actual DB Column name. Any idea why this is
happening ?

Steven





*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

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