Skip to main content
A newer version of this page is available. .

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.v18.2.Core.dll

Declaration

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

Property Value

Type Description
IEnumerable<Int32>

An array of row handles that correspond to data rows.

Remarks

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.

Example

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.

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()
            InitializeComponent()
            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
                    selectedRows.AddLast(Convert.ToInt32(item.Content))
                End If
            Next item
            e.BestFitRows = selectedRows
        End Sub
    End Class
End Namespace

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BestFitRows property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also