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
120
Hide column
posted

Hi,All

How to hide column in DataGrid for wpf.

Thanks.

 

  • 1650
    posted

    A field has a Visibility flag which can be set declaratively (XAML) or via code. I assume, you want to do this in code - here's a dummy snippet that shows/hides the first column of a given grid:

          Field field = myGrid.FieldLayouts[0].Fields[0];
          if (field.Visibility == Visibility.Visible)
          {
            field.Visibility = Visibility.Collapsed;
          }
          else
          {
            field.Visibility = Visibility.Visible;
          }

     

    hth Yes