473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Hide Columns in a datagrid

Hi there,

Can anyone tell me how to hide a column in a datagrid??.. I have tried to
assign a DataGridTableStyle to the datagrid, but it does not seems to work??
It shows all rows instead of the one speciffied?? see below..

Thanks

Dim ts As New DataGridTableStyle()
ts.MappingName = "Orders"

Dim colOrder As New DataGridTextBoxColumn()
With colOrder
.MappingName = "OrderID"
.HeaderText = "CustomerOrderID"
.Width = 100
.ReadOnly = True
End With
ts.GridColumnStyles.Add(colOrder)

DataGrid1.TableStyles.Add(ts)
ts = Nothing
colOrder = Nothing

DataGrid1.DataSource = CustomerOrdersDataSet.Tables(0)
Nov 21 '05 #1
7 1483
Henrik wrote:
Hi there,

Can anyone tell me how to hide a column in a datagrid??.. I have tried to
assign a DataGridTableStyle to the datagrid, but it does not seems to work??
It shows all rows instead of the one speciffied?? see below..

Thanks

Dim ts As New DataGridTableStyle()
ts.MappingName = "Orders"

Dim colOrder As New DataGridTextBoxColumn()
With colOrder
.MappingName = "OrderID"
.HeaderText = "CustomerOrderID"
.Width = 100
.ReadOnly = True
End With
ts.GridColumnStyles.Add(colOrder)

DataGrid1.TableStyles.Add(ts)
ts = Nothing
colOrder = Nothing

DataGrid1.DataSource = CustomerOrdersDataSet.Tables(0)


Try this.... You table has to be named the same as the
DataGridTableStyle mappingname.

Dim ts As New DataGridTableStyle()
ts.MappingName = "Orders"

Dim colOrder As New DataGridTextBoxColumn()
With colOrder
.MappingName = "OrderID"
.HeaderText = "CustomerOrderID"
.Width = 100
.ReadOnly = True
End With
ts.GridColumnStyles.Add(colOrder)

DataGrid1.TableStyles.Add(ts)
ts = Nothing
colOrder = Nothing

Dim DT as DataTable = CustomerOrdersDataSet.Tables(0)
DT.TableName = "Orders"
DataGrid1.DataSource =
Nov 21 '05 #2
Hendrik,

See this sample on our website

http://www.windowsformsdatagridhelp....3-a3539697edbd

I hope this helps,

Cor
Nov 21 '05 #3
Hi Cor,,

Thanks :) have been there a couple of times, but could't locate it?

-But im developing in mdi-forms, a get's an error on the parent-form, when i
creates the child form? .. an out of memory exception + Error creating
window handle.

Im creating the new form by:
Dim NewMDIChild As New frmOrders()
NewMDIChild.MdiParent = Me
NewMDIChild.Show()

-But chris has soveld the problem for me :) -YES
But it seems kind of slow??

But thank you for your time.

"Cor Ligthert [MVP]" wrote:
Hendrik,

See this sample on our website

http://www.windowsformsdatagridhelp....3-a3539697edbd

I hope this helps,

Cor

Nov 21 '05 #4
Hi Chris,,

Thank you :) that fixed the problem.
"Chris" wrote:
Henrik wrote:
Hi there,

Can anyone tell me how to hide a column in a datagrid??.. I have tried to
assign a DataGridTableStyle to the datagrid, but it does not seems to work??
It shows all rows instead of the one speciffied?? see below..

Thanks

Dim ts As New DataGridTableStyle()
ts.MappingName = "Orders"

Dim colOrder As New DataGridTextBoxColumn()
With colOrder
.MappingName = "OrderID"
.HeaderText = "CustomerOrderID"
.Width = 100
.ReadOnly = True
End With
ts.GridColumnStyles.Add(colOrder)

DataGrid1.TableStyles.Add(ts)
ts = Nothing
colOrder = Nothing

DataGrid1.DataSource = CustomerOrdersDataSet.Tables(0)


Try this.... You table has to be named the same as the
DataGridTableStyle mappingname.

Dim ts As New DataGridTableStyle()
ts.MappingName = "Orders"

Dim colOrder As New DataGridTextBoxColumn()
With colOrder
.MappingName = "OrderID"
.HeaderText = "CustomerOrderID"
.Width = 100
.ReadOnly = True
End With
ts.GridColumnStyles.Add(colOrder)

DataGrid1.TableStyles.Add(ts)
ts = Nothing
colOrder = Nothing

Dim DT as DataTable = CustomerOrdersDataSet.Tables(0)
DT.TableName = "Orders"
DataGrid1.DataSource =

Nov 21 '05 #5
Henrik,

I had seen the sample of Chris before I showed the link. The solution I
showed was withouth a style, however basicly it is only this.

\\\
dt.Columns("USA").ColumnMapping = MappingType.Hidden
///

Can you tell us why you could not reach our website (the error you got).

We had a very little program error yesterday for about 2 hours in very
special occassions however for the rest it should be online already for a
long time.

Cor
Nov 21 '05 #6
Hi Cor,,

ok thanks,, I will try that later to night :o)...

Regarding the site.... I did't get an error on your website... I just
haven't been lucky to find the exampel you linked to?... So the site works
just fine, and have been add'ed to my favorites :o)

Again thank you

"Cor Ligthert [MVP]" wrote:
Henrik,

I had seen the sample of Chris before I showed the link. The solution I
showed was withouth a style, however basicly it is only this.

\\\
dt.Columns("USA").ColumnMapping = MappingType.Hidden
///

Can you tell us why you could not reach our website (the error you got).

We had a very little program error yesterday for about 2 hours in very
special occassions however for the rest it should be online already for a
long time.

Cor

Nov 21 '05 #7
Hi Cor,,

ok thanks,, I will try that later to night :o)...

Regarding the site.... I did't get an error on your website... I just
haven't been lucky to find the exampel you linked to?... So the site works
just fine, and have been add'ed to my favorites :o)

Again thank you

"Cor Ligthert [MVP]" wrote:
Henrik,

I had seen the sample of Chris before I showed the link. The solution I
showed was withouth a style, however basicly it is only this.

\\\
dt.Columns("USA").ColumnMapping = MappingType.Hidden
///

Can you tell us why you could not reach our website (the error you got).

We had a very little program error yesterday for about 2 hours in very
special occassions however for the rest it should be online already for a
long time.

Cor

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrew Chen | last post by:
How do I hide any particular DataGrid Cell from visible, or any DataColumn for the matter?
6
by: Das | last post by:
Hi everyone, I'm using datagrid control to display the data. I want to hide column to be displayed into the data grid. I'm using the code as given below: Method given below is used to bind the...
4
by: Tim | last post by:
Hi, I am trying to hide the datagrid row header (the left most column that has the 'select' triangle in it which moves with the selected row). It seems to be fairly simple;...
1
by: J Gao | last post by:
Hi All, I am using Data binding with DataGrid. I need to hide column in the grid using DataGrid1.Columns(1).Visible = False But I get the following error message Description: An unhandled...
2
by: Thanh Nu | last post by:
Hi, I would like to hide a column in a web datagrid (with create columns automatically at runtime checked), and I cannot refer to the columns collection like this: DataGrid1.Columns(0).Visible...
8
by: Hanson | last post by:
I have a datagrid control in an aspx page. The datagrid columns will be dynamically generated according to the pre-page's search condition, I want to hide some columns in the datagrid. is that...
3
by: sivaraman.S | last post by:
Hi friends, How to hide a column in datagrid. regards, Sivaraman.S
5
by: J | last post by:
Ok, they have changed a lot of stuff in VB.net. How in the world do you hide a column on the Datagrid? -- Jason
1
by: nuhura01 | last post by:
Hi all.. I have a datagrid in my system and I preview the datagrid in other html page. Below are the code that I'm using: Dim oStringWriter As System.IO.StringWriter = New...
9
by: moondaddy | last post by:
using c# 3.5 I have list of business objects which I will use in lists for databinding and I want to hide some of the fields so they don't show up in the list control. some of my list will be:...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.