making a column invisible in code behind

J

Joel Ryan

hello,
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 =
Windows.Visibility.Hidden
'add the newly created xamdatagrid to the grid panel's
'children collection

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


MyxamDataGrid.RecordManager.Field.Visibility =
Windows.Visibility.Hidden

' End If

MyGrid.Children.Add(MyxamDataGrid)
'find way to make certain column invisible

' ds.Tables("dt").Columns("Title").DefaultValue =
Windows.Visibility.Visible = False
'ds.Container.Components.Item(Title).Equals(Visibility = 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",
"C"})
dt.Rows.Add(New Object() {"Gridiron Gang", "120 min.", "PG-13",
"C+"})
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
Joel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top