Back to Devexpress

DxRibbonComboBoxItem<TData, TValue>.TextFieldName Property

blazor-devexpress-dot-blazor-dot-dxribboncomboboxitem-2-ff061fd5.md

latest2.5 KB
Original Source

DxRibbonComboBoxItem<TData, TValue>.TextFieldName Property

Specifies the data source field that contains text for combo box items.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(null)]
[Parameter]
public string TextFieldName { get; set; }

Property Value

TypeDefaultDescription
Stringnull

The data source field’s name.

|

Remarks

Use the TextFieldName property when you bind the ribbon combo box item to a data source that stores custom objects (IEnumerable<CustomType>). This property specifies the name of the data source field that stores text for the combo box items.

If the TextFieldName property is not specified, the item searches for the Text field in the data source and uses this field as the text field. Otherwise, the editor populates its items with CustomType.ToString() values.

razor
...
<DxRibbonComboBoxItem Data="FontSizes"
                      @bind-Value="CurrentFontSize"
                      TextFieldName="@nameof(FontSizeInfo.Size)"
                      AllowUserInput="true"
                      NullText="Font Size"
                      Width="120px" />
...
@code {
    private FontSizeInfo CurrentFontSize { get; set; }
    private IEnumerable<FontSizeInfo> FontSizes => FontSizeInfo.DefaultFontSizes;
}
csharp
public class FontSizeInfo {
    public int Size { get; private set; }

    public FontSizeInfo(int size) {
        Size = size;
    }
    public static readonly FontSizeInfo[] DefaultFontSizes = new FontSizeInfo[] {
            new FontSizeInfo(8),
            new FontSizeInfo(10),
            new FontSizeInfo(12),
            new FontSizeInfo(14),
            new FontSizeInfo(18),
            new FontSizeInfo(24),
        };
}

Implements

DevExpress.Blazor.Ribbon.IRibbonComboBox<TData, TValue>.TextFieldName

See Also

DxRibbonComboBoxItem<TData, TValue> Class

DxRibbonComboBoxItem<TData, TValue> Members

DevExpress.Blazor Namespace