Solved

Hiding columns in Datagrid

Posted on 2006-07-18
10
184 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
ID: 17134408
is this for windows form or for asp.net?  Where are you calling this piece of code?
0
 
LVL 5

Expert Comment

by:mydasx
ID: 17134412
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
ID: 17137951
I am calling it from the form load.
0
 

Author Comment

by:lgropper
ID: 17137952
Windows form
0
 
LVL 5

Expert Comment

by:mydasx
ID: 17139608
are you assigning your styles to the grid?

Put this at the end of your code
Me.DataGrid1.TableStyles.Add(ts)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

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

Expert Comment

by:mydasx
ID: 17139891
dgstyles is the name of grid i see.
0
 
LVL 5

Accepted Solution

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

Author Comment

by:lgropper
ID: 17140465
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
ID: 17149504
I got it working by fiddling around with the datatable instead.

ex.
MyStyleTable.PictureColumn.ColumnMapping = MappingType.Hidden

Thanks for your effort.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

19 Experts available now in Live!

Get 1:1 Help Now