Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Hiding columns in Datagrid

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
lgropper
Asked:
lgropper
  • 5
  • 5
1 Solution
 
mydasxCommented:
is this for windows form or for asp.net?  Where are you calling this piece of code?
0
 
mydasxCommented:
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
 
lgropperAuthor Commented:
I am calling it from the form load.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
lgropperAuthor Commented:
Windows form
0
 
mydasxCommented:
are you assigning your styles to the grid?

Put this at the end of your code
Me.DataGrid1.TableStyles.Add(ts)
0
 
lgropperAuthor Commented:
Yes I have that exact line in the above code.
0
 
mydasxCommented:
dgstyles is the name of grid i see.
0
 
mydasxCommented:
looks good to me.  you put break points on it and they are being hit?
0
 
lgropperAuthor Commented:
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
 
lgropperAuthor Commented:
I got it working by fiddling around with the datatable instead.

ex.
MyStyleTable.PictureColumn.ColumnMapping = MappingType.Hidden

Thanks for your effort.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now