Articles in this section
Category / Section

How to clear the text in .NET MAUI AutoComplete (SfAutoComplete)?

2 mins read

This article demonstrates how to clear the text in the .NET MAUI AutoComplete (SfAutoComplete). To achieve this, you can set the SelectedItem property of the AutoComplete to null by handling the Button’s Clicked event.

XAML

<VerticalStackLayout Margin="10,0" Spacing="5">
        <Label Text="Choose Country Name" FontAttributes="Bold" FontSize="16"/>
        <editors:SfAutocomplete x:Name="autocomplete">
            <editors:SfAutocomplete.ItemsSource>
                <x:Array Type="{x:Type x:String}">
                    <x:String>United States</x:String>
                    <x:String>India</x:String>
                    <x:String>France</x:String>
                    <x:String>Italy</x:String>
                    <x:String>Germany</x:String>
                    <x:String>China</x:String>
                </x:Array>
            </editors:SfAutocomplete.ItemsSource>
        </editors:SfAutocomplete>
        <Button Text="Clear text" HorizontalOptions="Center" Clicked="OnButtonClicked"/>
</VerticalStackLayout>

C#

    private void OnButtonClicked(object sender, EventArgs e)
    {
        autocomplete.SelectedItem = null;
    }

Output

AutoCompleteClear.gif

Conclusion

Hope you enjoyed learning about how to clear the text in the .NET MAUI AutoComplete (SfAutoComplete).

You can refer to our .NET MAUI AutoComplete’s feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI AutoComplete documentation to understand how to present and manipulate data.

For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI AutoComplete (SfAutoComplete) and other .NET MAUI components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied