Silverlight AutoCompleteBox in VB.NET

Here we will look the use of AutoCompleteBox.
  • 2112

Introduction: AutoCompleteBox provide facility to text entry with drop-down list suggestion of matching items. like, if user type something in it then all matching item will show in drop-down list.
 To work with it, we take a silverlight application. Then we take  a AutoCompleteBox. The XAML code will look like below in editor

   <Grid x:Name="LayoutRoot" Background="White" Loaded="LayoutRoot_Loaded" Width="400"Height="300">
      <sdk:AutoCompleteBox Height="28" HorizontalAlignment="Left" Margin="10,10,0,0"Name="autoCompleteBox1"

 VerticalAlignment="Top" Width="120"/>       </Grid>

 Then, we create a array or list that will contain all suggestion for AutoCompleBox. we add array or list with AutoCompleBox by its ItemsSource property. The code for this is given below

    Dim months As String() = {"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE""JULY","AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"}
    AutoCompleteBox1.ItemsSource = months

 Then, we run the application. Here we look that if we press j in AutoCompleteBox then, all matching item like JANUARY,JUNE,JULY appears in drop-down list. like following figure

 Figure-1.gif

Figure-1
 

Now, we set the property IsTextCompletionEnabled to true, by clicking on checkbox. After setting this property, If we press a button then AutoCompleteBox will be filled with remaining text of top item in drop-down list. Means if we press m button, then AutoCompleteBox will be filled with ARCH. like below figure

 Figure-2.gif

Figure-2
 

AutoCompleteBox has FilterMode property which has different values that decides way of filtering items for suggestion in drop-down list. Some more important among those values are below

  • None: No filtering is performed. All the items of the will be appear in the drop-down list when we press any alphanumeric key. like figure 3.

 Figure-3.gif

Figure-3
 

  • StartsWith: Filter is performed with the first entered character. all the matched item is appeared in drop-down list. By default this property is set. like figure 4

 Figure-4.gif

Figure-4
 

  • StartsWithCaseSensitive: Filter is performed on the basis of matching with Capital an small letter. like figure 5

 Figure-5.gif

Figure-5
 

  • Contains: Filter is performed with matching with input text to all items of array or list. only those item will be appeared , to which input text is sub part. like figure 6

 Figure-6.gif

Figure-6

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.