Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

How to hide a column in a DataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
darin_dimitrov@hotmail.com - 09 Dec 2004 11:09 GMT
Hello,

I have a System.Windows.Forms.DataGrid which is bound to a DataSet
containing a table and columns such as user_id, user_firstname,
user_lastname, etc... How can I force the DataGrid component NOT to
display the user_id column without narrowing my sql query because the
program logic needs this column. I tried the following:

DataSet1.ReadXml('users.xml');
DataSet1.Tables['users'].Columns['user_id'].ColumnMapping :=
MappingType.Hidden;

This code works well and prevents the user_id column from being
displayed in the DataGrid. I can also access the values of the user_id
column programatically by calling:

string currentUserId =
DataSet1.Tables['users'].Rows[DataSet1.CurrentRowIndex].Item['user_id'].ToString();

The problem is when I call DataSet1.WriteXml('users.xml'); to save
back any changes to the underlying backend - the "user_id" attribute is
not persisted at all and the structure of the xml file is modified!!
Could you please help me with this issue?
Rakesh Rajan - 10 Dec 2004 04:25 GMT
Hi,

Columns set with MappingType.Hidden will not be written when you call
WriteXML.

Instead, try setting the GridColumStyle.Width to zero as specified in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbts
kaddingdeletingorhidingcolumns.asp


HTH,
Rakesh Rajan

> Hello,
>
[quoted text clipped - 19 lines]
> not persisted at all and the structure of the xml file is modified!!
> Could you please help me with this issue?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.