469,647 Members | 1,682 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

making a column invisible in code behind

I'm currently working with a xamdatagrid, this grid is bound to a dataset as
its source, and what im trying to do is, based on the column name(or the
field name as the xamdatagrid calls it i think) i want to make that field
invisible but every time ive tried it says object not referenced to an
instance of an object. heres the code im working with, i figure if i can
figure it out here i can use it in another program
Imports System.Data
Imports Infragistics.Windows.DataPresenter
Class Window1
Sub Samp_Loaded(ByVal o As Object, ByVal e As RoutedEventArgs)
'create data using GenerateData Method
Dim ds As DataSet = generatedata()
'create an instance of xamdatagrid
Dim MyxamDataGrid As New XamDataGrid
'give name
MyxamDataGrid.Name = "XamDataGrid1"
'set its datasource property to the default view of
'the dataset created earlier
MyxamDataGrid.DataSource = ds.Tables(0).DefaultView

' MyxamDataGrid.DefaultFieldLayout.Visibility =
'add the newly created xamdatagrid to the grid panel's
'children collection

'If MyxamDataGrid.RecordManager.Field.Name = "Title" Then
MyxamDataGrid.RecordManager.Field.Visibility =

' End If

'find way to make certain column invisible

' ds.Tables("dt").Columns("Title").DefaultValue =
Windows.Visibility.Visible = False
'ds.Container.Components.Item(Title).Equals(Visibi lity = False)

End Sub
Function generatedata() As DataSet
Dim ds As New DataSet
Dim dt As DataTable = ds.Tables.Add("TopMovies")

dt.Columns.Add("Title", GetType([String]))
dt.Columns.Add("Running Time", GetType(String))
dt.Columns.Add("MPAA Rating", GetType(String))
dt.Columns.Add("Critics Rating", GetType(String))

dt.Rows.Add(New Object() {"Open Season", "1 hr. 40 min.", "PG",
dt.Rows.Add(New Object() {"Gridiron Gang", "120 min.", "PG-13",
dt.Rows.Add(New Object() {"The Illusionist", "1 hr. 49 min.", _
"PG-13", "B"})
dt.Rows.Add(New Object() _
{"Talladega Nights: The Ballad of Ricky Bobby", "1 hr. 50 min.", _
"PG-13", "B"})
dt.Rows.Add(New Object() _
{"Pirates of the Caribbean: Dead Man's Chest", "145 min.", _
"PG-13", "B-"})

Return ds
End Function

End Class
thank you in advance

Jun 27 '08 #1
0 1173

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Harry Gould | last post: by
10 posts views Thread by Carlos | last post: by
2 posts views Thread by Mariano | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.