making a column invisible in code behind

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joel Ryan

    making a column invisible in code behind

    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.Wi ndows.DataPrese nter


    Class Window1
    Sub Samp_Loaded(ByV al 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.N ame = "XamDataGri d1"
    'set its datasource property to the default view of
    'the dataset created earlier
    MyxamDataGrid.D ataSource = ds.Tables(0).De faultView

    ' MyxamDataGrid.D efaultFieldLayo ut.Visibility =
    Windows.Visibil ity.Hidden
    'add the newly created xamdatagrid to the grid panel's
    'children collection

    'If MyxamDataGrid.R ecordManager.Fi eld.Name = "Title" Then


    MyxamDataGrid.R ecordManager.Fi eld.Visibility =
    Windows.Visibil ity.Hidden

    ' End If

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

    ' ds.Tables("dt") .Columns("Title ").DefaultV alue =
    Windows.Visibil ity.Visible = False
    'ds.Container.C omponents.Item( Title).Equals(V isibility = 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

Working...