473,671 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to hide one column in datagrid?

Hi~
I want to know if I want to hide a column in datagrid because I don't want
to show that column of data.
How can I do this?

Sidney
Feb 10 '06 #1
4 6484
Well, I think it depends on what is the DataSource for your Datagrid. If you
are loading data from a DataSet or DataTable, you might prefer not to load
that particular column at all, into your DataSet.

Additionally, to create a customized view of a table, create a collection of
DataGridColumnS tyle objects, and set each column's MappingName to the
ColumnName of a column that you want to show in the grid. To hide a column,
set its MappingName to something other than a valid ColumnName.

Hope this helps,

Regards,

Cerebrus.
Feb 10 '06 #2
Create a DataGridTableSt yle, set its MappingName to the name of your
table, create DataGridColumnS tyle objects for each of your column,
setting the MappingName equal to the ColumnName and add them to the
DataGridTableSt yle. Add the table style to the DataGrid's TableStyles
collection. Then you can hide the desired column by setting the Width
property of DataGridColumnS tyle object of the specific column equal to
0

Regards
GM

Feb 10 '06 #3
Sidney,

Another method, be aware that it hides than the column everywhere.

http://www.vb-tips.com/default.aspx?...3-a3539697edbd

I hope this helps,

Cor
Feb 10 '06 #4
DataGrid1.Colum ns(0).Visible = False

Sonu Kapoor [MVP]
---
Posted via www.DotNetSlackers.com
Feb 10 '06 #5

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

Similar topics

6
6278
by: CBuck | last post by:
Hi, I was wondering if it was possible to hide the first column of the datagrid (windows form control). The column that I am referring to is the column created by the control that is gray in color and contains the selection arrow. My goal is to use the datagrid in place of a ListView control for performance reasons. To keep this new control like a ListView control, I need to not display this column. Any ideas? Thanks in advance, C. Buck
6
8407
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 data grid with the db: public static void DataGrid(DataGrid DG,string sql) { //Initialize connection with the db
2
4304
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 = False (the message at runtime is something like index out of range, and under the debuger, I discover that the attribute count of the columns collection is 0!) Below is my piece of code.
1
2730
by: enak | last post by:
I populate a datagrid by setting the datasource to a datatable. I then, bind them. After that I try to hide the last column but am not able to. I get an error message. Here is my code: Me.dgReport.DataSource = ds.Tables("tFirst") Me.dgReport.DataBind() Me.dgReport.Columns(7).Visible = False
8
7312
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 anyway to do that?
3
1710
by: sivaraman.S | last post by:
Hi friends, How to hide a column in datagrid. regards, Sivaraman.S
5
7808
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
2
18883
by: Keithb | last post by:
I need to hide a GridView's "edit" column if the user's role does not support editing. However, the column's Visible property does not support databinding. Is there a workaround? Thanks, Keith
1
2997
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 System.IO.StringWriter Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
1
2288
by: TonyJ | last post by:
Hello! Assume I have a datasource consisting of a database table. This table has 5 column. If I now want to use a bound datagrid but want to display only 4 of these 5 columns is that possible. How is that done?
0
8474
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8392
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5692
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.