Auto Fit

 
TaskAssigned ToStart DateDue DatePriorityProgress
Simplify & Clarify Product Messaging
John Heart4/3/20184/14/2018LowIn progress
Create Action Plan to Improve Customer Engagement
Robert Reagan8/8/20174/8/2018MediumIn progress
Increase Average Subscription Price
Wally Hobbs8/9/20179/13/2017LowIn progress
Reduce Churn to Less than 1% Monthly
Arnie Schwartz2/12/20185/1/2018LowIn progress
Finalize the Content Strategy
Stu Pizaro3/10/20184/11/2018HighIn progress
Grow Subscriber Base by 5% per Week
Sandra Johnson7/24/20172/10/2018LowIn progress
Increase the CTR% to Above Industry Average 3.5%
Karen Goodson7/11/20174/15/2018LowIn progress
Close the Final Budget
Hannah Brookly6/5/20176/18/2017LowIn progress
Achieve Record Metrics in All Areas
Ed Holmes4/24/20172/3/2018LowIn progress
Begin Content Review
Victor Norris4/27/20172/25/2018MediumIn progress
Produce Online Survey
Karen Goodson10/14/20173/25/2018LowIn progress
Improve Our Content and Its Distribution
Arnie Schwartz4/29/201711/9/2017HighIn progress
Update Old Content
Maggie Boxter2/2/20184/2/2018MediumIn progress
Map and Analyze Marketing Channels
Samantha Bright7/5/20174/19/2018LowIn progress
Research and Improve Customer Satisfaction
Robin Cosworth10/27/20174/30/2018MediumIn progress
Present an Action Plan for Next Quarter
Arnie Schwartz6/6/20175/11/2018HighIn progress
Achieve Record Revenues While Increasing Profitability
Samantha Piper10/21/20172/28/2018LowIn progress
Hit Quarterly Revenue of Over $1000000
Clark Morgan8/30/20171/7/2018LowIn progress
Start Sales in 2 New Countries
Brad Farkus9/26/201710/4/2017LowIn progress
Increase Gross Profit Margin from 54% to 63%
Sandra Johnson7/14/201710/25/2017LowIn progress
Data grid with 37 rows and 6 columns
0 rows are selected

Call the AutoFitColumnWidths method to resize columns based on content (best fit).

This method takes header, data cell, and summary value content into account. The auto fit algorithm uses the same units as the column's Width property value.

  • If a column's width is set in pixels, the final width is in pixels. The column's width fits its content.
  • If a column's width is set in percentages or not set, the final width is in percentages. Columns may shrink or grow depending on the available space.

Depending on calculated values, the following outcomes are possible:

  • Columns occupy the entire width of the component. Example: all or several widths are in percentages.
  • A scroll bar appears. Example: all widths are in pixels and the content is too wide.
  • Empty space remains. Example: all widths are in pixels and the content is not wide enough.

In this demo, Task, Assigned To, and Progress column widths are in pixels, and their content is always fully visible. Other column widths are not specified – as such, these columns may shrink (to the limit set by MinWidth).