Ticket T369034
Visible to All Users

WPF gridcontrol best fit all columns

created 9 years ago

Hello,

How can I best fit all columns?  Currently, my users have to right-click a column heading and select Best Fit (all columns) . I thought the below xaml would solve the issue, but it doesn't apply best fit at run-time.  Also, i noticed that after the data is refreshed the best fit is lost; do i need to set best fit programmatically after best fit and if so could you please provide an example?  If needed see attached screen shot of what I'd like to do.

<dxg:GridControl x:Name="dgTest" AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" Grid.Row="2" SelectionMode="Cell" OptimizeSummaryCalculation="True" ClipboardCopyMode="IncludeHeader">            <dxmvvm:Interaction.Behaviors>                <behaviors:DynamicConditionBehavior/>            </dxmvvm:Interaction.Behaviors>                        <dxg:GridControl.View>                <dxg:TableView x:Name="view" AllowPerPixelScrolling="True" ShowTotalSummary="True" AllowEditing="False" ShowGroupPanel="False" BestFitMode="AllRows" />

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hi Jimmy,

Since the Best Fit feature requires a lot of resources, it may hang the application when the DXGrid control has a lot of data. So, the control doesn't perform best fit operations automatically. Thus, you need to call the TableView.BestFitColumns method manually when required. E.g., call it once the control's ItemsSource is changed.

Regards,
Alex

    Comments (3)
    JS JS
    Jimmy Strain 1 9 years ago

      Thanks Alexander for the explanation and suggestion.  With your explanation, I'll use it sparingly and play around with it to only make use where it makes sense.
      Jimmy

      DevExpress Support Team 9 years ago

        I'm happy to hear that my assistance was helpful. Should you need further assistance, feel free to contact us.

        JS JS
        Jimmy Strain 1 9 years ago

          Just implemented it after my BindData method that sets the itemsource.  It works exactly as expected with not much performance issues.
          Thanks again Alexander.
          Jimmy

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.