lgropper
asked on
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.Ad d(ts)
Me.dgStyles.RowHeadersVisi ble = True
Me.dgStyles.ReadOnly = True
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.Ad
Me.dgStyles.RowHeadersVisi
Me.dgStyles.ReadOnly = True
is this for windows form or for asp.net? Where are you calling this piece of code?
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.
ASKER
I am calling it from the form load.
ASKER
Windows form
are you assigning your styles to the grid?
Put this at the end of your code
Me.DataGrid1.TableStyles.A dd(ts)
Put this at the end of your code
Me.DataGrid1.TableStyles.A
ASKER
Yes I have that exact line in the above code.
dgstyles is the name of grid i see.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
ASKER
I got it working by fiddling around with the datatable instead.
ex.
MyStyleTable.PictureColumn .ColumnMap ping = MappingType.Hidden
Thanks for your effort.
ex.
MyStyleTable.PictureColumn
Thanks for your effort.