By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Hiding a column in a datagrid?

P: n/a
I have a datagrid that uses a dataview object for its datasource. The
dataview contains a unique row identifier column. I don't want to display
this column in the datagrid. I need the unique row Identifier column so that
I can run updates on the SqlAdapter object. Is there a way to hide this
column from the datagrid?

Dim dv1 As New DataView(ds.Tables("tbl1"))
dv1.AllowNew = False
dgr1.DataSource = dv1 '--dgr1 is the datagrid

I checked the dropdown lists for dv1 and dgr1 but did recognize anything for
hiding a column.

Thanks,
Rich
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I figured it out:

dv1.Table.Columns(0).ColumnMapping = MappingType.Hidden

"Rich" wrote:
I have a datagrid that uses a dataview object for its datasource. The
dataview contains a unique row identifier column. I don't want to display
this column in the datagrid. I need the unique row Identifier column so that
I can run updates on the SqlAdapter object. Is there a way to hide this
column from the datagrid?

Dim dv1 As New DataView(ds.Tables("tbl1"))
dv1.AllowNew = False
dgr1.DataSource = dv1 '--dgr1 is the datagrid

I checked the dropdown lists for dv1 and dgr1 but did recognize anything for
hiding a column.

Thanks,
Rich

Nov 21 '05 #2

P: n/a
Hi,

I would add a tablestyle to my datagrid. You can specify which
columns are shown and their format.

http://msdn.microsoft.com/library/de...asicprimer.asp

http://msdn.microsoft.com/library/de...stdatagrid.asp

Ken
---------------
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I figured it out:

dv1.Table.Columns(0).ColumnMapping = MappingType.Hidden

"Rich" wrote:
I have a datagrid that uses a dataview object for its datasource. The
dataview contains a unique row identifier column. I don't want to display
this column in the datagrid. I need the unique row Identifier column so
that
I can run updates on the SqlAdapter object. Is there a way to hide this
column from the datagrid?

Dim dv1 As New DataView(ds.Tables("tbl1"))
dv1.AllowNew = False
dgr1.DataSource = dv1 '--dgr1 is the datagrid

I checked the dropdown lists for dv1 and dgr1 but did recognize anything
for
hiding a column.

Thanks,
Rich

Nov 21 '05 #3

P: n/a
I just finished playing around with the datagrid table styles. My datagrid
has 22 fields. That was way less fun than doing the dv1...columnmapping
thing. Mostly because I couldn't get the tablestyle to work. I set the
desired column width to 0 for the column I want to hide, but it did not get
hidden. So I played around with dgr1.TableStyles(0) in the code and got
error messages. How do I hide my column with the tablestyles?

"Ken Tucker [MVP]" wrote:
Hi,

I would add a tablestyle to my datagrid. You can specify which
columns are shown and their format.

http://msdn.microsoft.com/library/de...asicprimer.asp

http://msdn.microsoft.com/library/de...stdatagrid.asp

Ken
---------------
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I figured it out:

dv1.Table.Columns(0).ColumnMapping = MappingType.Hidden

"Rich" wrote:
I have a datagrid that uses a dataview object for its datasource. The
dataview contains a unique row identifier column. I don't want to display
this column in the datagrid. I need the unique row Identifier column so
that
I can run updates on the SqlAdapter object. Is there a way to hide this
column from the datagrid?

Dim dv1 As New DataView(ds.Tables("tbl1"))
dv1.AllowNew = False
dgr1.DataSource = dv1 '--dgr1 is the datagrid

I checked the dropdown lists for dv1 and dgr1 but did recognize anything
for
hiding a column.

Thanks,
Rich


Nov 21 '05 #4

P: n/a
Rich,

How do I hide my column with the tablestyles?

When you do not "map" it, than it will not be showed using table styles.

When you still see them all, than there is probably something wrong in the
styles.

Cor
Nov 21 '05 #5

P: n/a
Hi,

Rich wrote:
I just finished playing around with the datagrid table styles. My datagrid
has 22 fields. That was way less fun than doing the dv1...columnmapping
thing. Mostly because I couldn't get the tablestyle to work. I set the
desired column width to 0 for the column I want to hide, but it did not get
hidden. So I played around with dgr1.TableStyles(0) in the code and got
error messages. How do I hide my column with the tablestyles?


I suggest you checkout the Windows Forms FAQ at
www.syncfusion.com/faq/windowsforms
There is a very detailed section about the Datagrid as well - that should
answer your TableStyle/ColumnStyle questions as well as a bunch of other
ones you'll probably come across in the near future. ;-)

Cheers,
Olaf
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.