Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 27th, 2005, 12:44 PM
Wiharu Wiharu is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: McDonough, Georgia
Posts: 30 Wiharu User rank is Private First Class (20 - 50 Reputation Level)Wiharu User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 11 h 18 m 13 sec
Reputation Power: 4
Send a message via MSN to Wiharu Send a message via Google Talk to Wiharu
Arrow "hiding" columns in Datagrid

OK, I have 20 columns in a datagrid, but I only want to show about 10 of them...

I am using this code which dumps all 20 columns into my app:
Code:
SqlDataAdapter1.Fill(DataSet11)
dgQuestions.DataSource = DataSet11.Tables(0)



I looked on a few sites and they say that this should work to "hide" a column:
Code:
dgQuestions.Columns(1).ColumnMapping = MappingType.Hidden

Of course this is supposted to hide column #1. I am working in Visual Studio.Net and when I try this code, I get a blue underline and the error says: "Columns" is not a member of System.Windows.Forms.DataGrid

Anyone ideas would be nifty.

Reply With Quote
  #2  
Old May 27th, 2005, 02:02 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 7 h 9 m 21 sec
Reputation Power: 469
Example:
Code:

Try
   Conn = New SqlConnection("Your ConnectionString")
   da = New SqlDataAdapter("SELECT DepartmentID, DepartmentName FROM Department", Conn)
   ds = New DataSet

   da.Fill(ds, "Dept")

   Next line hides column.
   ds.Tables(0).Columns("DepartmentID").ColumnMapping = MappingType.Hidden
   DataGrid1.SetDataBinding(ds, "Dept")

Catch ex As Exception
   MessageBox.Show(ex.Message)
Finally
   Conn.Close()
End Try

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > "hiding" columns in Datagrid


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT