Skip to main content

CustomBestFitEventArgsBase.BestFitRows Property

Rows that should be taken into account when calculating the optimal width of CustomBestFitEventArgs.Column.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v22.1.Core.dll

NuGet Package: DevExpress.Wpf.Grid.Core


public IEnumerable<int> BestFitRows { get; set; }

Property Value

Type Description

An array of row handles that correspond to data rows.


The BestFitRows property allows you to specify the exact cells in the processed column to be used to calculate its optimal width. Set the BestFitRows property to a collection of row handles. The column’s optimal width will be calculated according to the content of data cells that correspond to the processed column and the specified rows.

To learn more, see Best Fit in Columns Layout and Width.


This example shows how to specify rows that should be taken into account when calculating the optimal width of a column. Specify required rows by selecting their handles in the list box, invoke the Best Fit method by right-clicking the column's header and choosing the correspondent menu item.

View Example

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Controls

Namespace WpfApplication5
    ''' <summary>
    ''' Interaction logic for MainWindow.xaml
    ''' </summary>
    Partial Public Class MainWindow
        Inherits Window
        Public Sub New()
            Dim source() As String = { "123456789", "1234567890", "12345678901", "123456789012" }
            gridControl1.ItemsSource = source

        End Sub
        Private Sub tableView1_CustomBestFit(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.CustomBestFitEventArgs)
            Dim selectedRows As New LinkedList(Of Integer)()
            For Each item As ListBoxItem In listBoxEdit1.SelectedItems
                If item.IsEnabled Then
                End If
            Next item
            e.BestFitRows = selectedRows
        End Sub
    End Class
End Namespace
See Also