Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: DataGridControl AutoCreateColumns Auto-Size Columns

$
0
0
Hi,

You can call the column.GetFittedWidth() once the Grid is loaded. So the DataGridControl_Loaded handler is a good place.
But this column.GetFittedWidth() method call will return the fitted width of the columnManagerCell, not its content.

If you want to have the widest visible value for a column, you must use a Dispatcher to call GetFittedWidth() in the Loaded event :
  private void DataGridControl_Loaded( object sender, RoutedEventArgs e )
    {
      var grid = sender as DataGridControl;

      this.Dispatcher.Invoke( DispatcherPriority.ApplicationIdle, new Action( delegate ()
      {
        foreach( Column column in grid.Columns )
        {
          double width = column.GetFittedWidth();
          if( width > 0 )
            column.Width = width;
        }
      } ) );
    }
――――
Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>