Inteliscape
asked on
hide column in datagrid
I have this code behind on pageload :
Dim dss As New DataSet
dss = myProfile.getsubjects(cate goryid)
datagrid1.DataSource = dss.Tables(0)
my dss has 5 columns but i want to show only 2 of them on datagrid. I don't want to cut the 3 of them as i use all column info.
Just want to show only the 2 columns.
How i change the column name to be diferent from the name of the sql tables i have on my database?
Thanx
Dim dss As New DataSet
dss = myProfile.getsubjects(cate
datagrid1.DataSource = dss.Tables(0)
my dss has 5 columns but i want to show only 2 of them on datagrid. I don't want to cut the 3 of them as i use all column info.
Just want to show only the 2 columns.
How i change the column name to be diferent from the name of the sql tables i have on my database?
Thanx
ASKER
DataGrid.Columns(index).Vi sible = False
When i write the above i get this message :
'Columns' is not a member of 'System.Windows.Forms.Data grid'
When i write the above i get this message :
'Columns' is not a member of 'System.Windows.Forms.Data
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry for not mentioning before but i am working on a windows form and not a web one. The code you've sent me before works well in the case of a web application but not a windows one.
Can you please help me on the environment i am working at?
Can you please help me on the environment i am working at?
Ans. DataGrid.Columns(index).Vi
See also: Mapping type?
Set DataColumn.MappingType as MappingType.Hidden
ONE MORE VERSION: GRID ONLY:
The grid part of a DataGrid is represented by a table. The TableStyles property provides to this table. TableStyles property returns an object of type DataGridTableStyle, which provides access to all columns in the form of DataGridColumnStyles collection. The GridColumnStyles property of DataGridTableStyle returns it, from where you can get one DataGridColumnStyle. The DataGridColumnStyle represents the style of a column and you need to set Width property of DataGridColumnStyle to 0.
Something like this:
For Each dgt As DataGridTableStyle In myDataGrid.TableStyles
Console.WriteLine(dgt.Mapp
For Each dgc As DataGridColumnStyle In dgt.GridColumnStyles
dgc.Width = 0
Next dgc
Next dgt
Source: http://www.vbdotnetheaven.com/Uploadfile/prvn_131971/HideDataGridcolumnInVB11172005020153AM/HideDataGridcolumnInVB.aspx?ArticleID=daa8d4d5-7b0d-4265-9f8e-ed62aaabb58e