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.v20.1.Core.dll

Declaration

public IEnumerable<int> BestFitRows { get; set; }
Public Property BestFitRows As IEnumerable(Of Integer)

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.

Examples

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
See Also