![]() ![]() Private Sub CheckBox_Unchecked(ByVal sender As Object, ByVal e As RoutedEventArgs)ĭim columns As ObservableCollection(Of DataGridColumn) = DG1.Columns 'Make each column in the collection visibleįor Each col As DataGridColumn In DG1.Columns Private Sub CheckBox_Checked(ByVal sender As Object, ByVal e As RoutedEventArgs) 'Set properties on the columns during auto-generationĮ.Column.Visibility = Visibility.Collapsed Private Sub DG1_AutoGeneratingColumn(ByVal sender As Object, ByVal e As DataGridAutoGeneratingColumnEventArgs) ![]() set the visibility for each column so only 4 columns are visible ObservableCollection columns = DG1.Columns Private void CheckBox_Unchecked(object sender, RoutedEventArgs e) Make each column in the collection visibleįoreach (DataGridColumn col in DG1.Columns) Private void CheckBox_Checked(object sender, RoutedEventArgs e) Set properties on the columns during auto-generationĮ.Column.Visibility = Visibility.Visible Į.Column.Visibility = Visibility.Collapsed Private void DG1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) The following example shows how to set properties on columns in the collection when they are auto-generated and when an event occurs. 'Delete the first column whether visible or not Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Delete the first column whether visible or not Private void Button_Click(object sender, RoutedEventArgs e) The following example shows how to remove a column from the collection. 'The column inherits its DataContext from the DataGrid, so you don't set the source 'Create a Binding object to define the path to the DataGrid.ItemsSource property 'Create a new column to add to the DataGrid The column inherits its DataContext from the DataGrid, so you don't set the source Create a Binding object to define the path to the DataGrid.ItemsSource property Create a new column to add to the DataGridĭataGridTextColumn textcol = new DataGridTextColumn() The following example shows how to add a column to the collection. The collection of columns in the DataGrid. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |