Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
455
using xamdatagrid to hide columns programmically
posted

hello,

I am using the xamdatagrid and i was wondering if there was a way to access the column( or field i believe you call it), name and based off that name hide the column. I'm sure its really easy but i cant figure it out for the life of me. here is the code im currently experimenting on:

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


    End Function

End Class

Thank you in advance

Joel