473,418 Members | 2,091 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,418 software developers and data experts.

Hiding a column in a datagrid?

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
5 3685
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kevin | last post by:
Hi Al Can someone tell me how to hide colums in a datagrid. I have a one datagrid that is a master and child and I would like to hide specific columns, how do I do this TI Kevin
2
by: MrNobody | last post by:
I found some tutorial which had the following example for hiding columns in a DataGrid: ...
0
by: lanky_tx | last post by:
Hello, I am trying to hide a column in a child table within a windows form DataGrid control. I am populating the Datagrid datasource with an dataset which is populated with hierarchical XML...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
0
by: Michelle Stone | last post by:
I have several Data Adapters, and depending on certain conditions, I set one of them as the DataSource for a datagrid on my web form. In each of the data adapters, I have the primary key of the...
7
by: David Freeman | last post by:
Hi There! Below is my VB.NET code... Dim strSQL As String strSQL = "SELECT , FROM Customers GROUP BY , , " Dim oleConn As OleDbConnection = Nothing
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
1
by: jack | last post by:
Hi all, My datagrid have too many columns which are going out of screen. one of the solution is to group the columns and make only the total column visible at the initial stage. What now i...
1
by: Dica | last post by:
i need to allow the user to select a row from my dataGrid for editing. as such, i include the record ID in the first column and then extract like so when retrieving the record details: protected...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.