Skip to main content

AutoCompleteColumn.ItemsSourceProvider Property

Gets or sets the data provider that supplies suggestions. This is a bindable property.

Namespace: DevExpress.Maui.DataGrid

Assembly: DevExpress.Maui.DataGrid.dll

NuGet Package: DevExpress.Maui.DataGrid

Declaration

public ItemsSourceProviderBase ItemsSourceProvider { get; set; }

Property Value

Type Description
ItemsSourceProviderBase

A data provider that supplies suggestions.

Remarks

Asynchronous Data Provider

Attach the AsyncItemsSourceProvider to the column and handle its ItemsRequested event. Use the Request event argument to specify the method that returns suggestions. To get the text entered in the cell and pass it to the specified method, use the Text event argument.

You can also specify the following options:

  • RequestDelay – the time that should elapse after the text is changed and the request is called. Use this parameter to reduce the number of requests as a user types.
  • CharacterCountThreshold – the number of entered characters after which the provider starts to make requests. For example, the provider can make requests only if a user enters at least three characters.

The provider cancels the previous request if a new request is submitted. You can use the CancellationToken event argument to cancel the previous request.

Synchronous Data Provider

The FilteredItemsSourceProvider filters an existing collection based on filter settings. Use the ItemsSource property to specify the collection of suggestions. The following properties specify how the provider searches for suggestions in the collection:

Examples

The example below uses the AsyncItemsSourceProvider to supply items for the AutoCompleteColumn:

<dxg:DataGridView ItemsSource="{Binding Path=Employees}">
    <dxg:DataGridView.Columns>
        <dxg:AutoCompleteColumn FieldName="JobTitle">
            <dxg:AutoCompleteColumn.ItemsSourceProvider>
                <dxe:AsyncItemsSourceProvider ItemsRequested="ItemsRequested"
                                              RequestDelay="500"
                                              CharacterCountThreshold="2"/>
            </dxg:AutoCompleteColumn.ItemsSourceProvider>                
        </dxg:AutoCompleteColumn>
    </dxg:DataGridView.Columns>
</dxg:DataGridView>
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Maui.Controls;

namespace DemoCenter.Forms.Views {
    public partial class FirstLookView : ContentPage {
        public FirstLookView() {
            InitializeComponent();
            BindingContext = new EmployeesRepository();
        }

        private void ItemsRequested(object sender, ItemsRequestEventArgs e) {
            EmployeesRepository employeesRepository = BindingContext as EmployeesRepository;
            e.Request = () => {
                return employeesRepository.JobTitles.Where(i => i.StartsWith(e.Text, StringComparison.CurrentCultureIgnoreCase)).ToList();
            };
        }
    }
    public class EmployeesRepository {
        public IList<Employee> Employees { get; set; }
        public IList<string> JobTitles { get; set; }
    }
    public class Employee {
        public string JobTitle { get; set; }
    }
}

The example below uses the FilteredItemsSourceProvider to supply suggestions for the AutoCompleteColumn.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
             xmlns:dxg="clr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid"
             xmlns:scg="clr-namespace:System.Collections.Generic;assembly=netstandard">
    <ContentPage.Content>
        <dxg:DataGridView ItemsSource="{Binding Path=Employees}">
            <dxg:DataGridView.Columns>
                <dxg:AutoCompleteColumn FieldName="JobTitle">
                    <dxg:AutoCompleteColumn.ItemsSourceProvider>
                        <dxe:FilteredItemsSourceProvider FilterCondition="Contains"
                                                         FilterComparisonType="CurrentCultureIgnoreCase">
                            <dxe:FilteredItemsSourceProvider.ItemsSource>
                                <scg:List x:TypeArguments="x:String">
                                    <x:String>Chief Executive Officer</x:String>
                                    <x:String>Network Administrator</x:String>
                                </scg:List>
                            </dxe:FilteredItemsSourceProvider.ItemsSource>
                        </dxe:FilteredItemsSourceProvider>
                    </dxg:AutoCompleteColumn.ItemsSourceProvider>                
                </dxg:AutoCompleteColumn>
            </dxg:DataGridView.Columns>
        </dxg:DataGridView>
    </ContentPage.Content>
</ContentPage>
See Also