• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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