Solved

Hiding columns in Datagrid

Posted on 2006-07-18
10
183 Views
Last Modified: 2010-04-23
I have this code. Has zero effect on the column "style". Please help.

        Dim c As DataGridTextBoxColumn
        Dim ts As DataGridTableStyle

        Me.dgStyles.DataSource = MyStyleTable
        ts = New DataGridTableStyle
        ts.MappingName = "tstyle"

        c = New DataGridTextBoxColumn
        c.MappingName = "Style"
        c.Width = 0
        c.HeaderText = "Style"
        ts.GridColumnStyles.Add(c)
        Me.dgStyles.TableStyles.Add(ts)
       
        Me.dgStyles.RowHeadersVisible = True

        Me.dgStyles.ReadOnly = True
0
Comment
Question by:lgropper
  • 5
  • 5
10 Comments
 
LVL 5

Expert Comment

by:mydasx
Comment Utility
is this for windows form or for asp.net?  Where are you calling this piece of code?
0
 
LVL 5

Expert Comment

by:mydasx
Comment Utility
typically when i see no net effect when i am setting up a control, it means that either i forgot to call my method that sets up the control, or the control is being setup differently later in the execution.  Need more info to help.
0
 

Author Comment

by:lgropper
Comment Utility
I am calling it from the form load.
0
 

Author Comment

by:lgropper
Comment Utility
Windows form
0
 
LVL 5

Expert Comment

by:mydasx
Comment Utility
are you assigning your styles to the grid?

Put this at the end of your code
Me.DataGrid1.TableStyles.Add(ts)
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:lgropper
Comment Utility
Yes I have that exact line in the above code.
0
 
LVL 5

Expert Comment

by:mydasx
Comment Utility
dgstyles is the name of grid i see.
0
 
LVL 5

Accepted Solution

by:
mydasx earned 500 total points
Comment Utility
looks good to me.  you put break points on it and they are being hit?
0
 

Author Comment

by:lgropper
Comment Utility
Yeah. I just don't get it. I have tried everything. I added the field names in manually (not with code) by draggin the element control onto the dataset and adding 8 column names. Could this have anything to do with it?
0
 

Author Comment

by:lgropper
Comment Utility
I got it working by fiddling around with the datatable instead.

ex.
MyStyleTable.PictureColumn.ColumnMapping = MappingType.Hidden

Thanks for your effort.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now