This is a migrated thread and some comments may be shown as answers.

AutoComplete - Programmatically

2 Answers 132 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 04 May 2012, 04:30 PM
Hi,

Is it possible to set the AutoComplete text programmatically?

I have the following ListBox:
<telerik:RadListBox MinWidth="100" MaxHeight="250" x:Name="radListBox"
                    Grid.ColumnSpan="2" Visibility="Collapsed"
                    HorizontalAlignment="Left" VerticalAlignment="Top"
                    CanAutocompleteSelectItems="True" IsTextSearchEnabled="True" TextSearchMode="Contains" TextPath="Name"
                    ItemTemplate="{StaticResource AutoCompleteListBoxTemplate}"
                    ItemsSource="{Binding autoCompleteListItems}"
                    MouseDoubleClick="radListBox_MouseDoubleClick" MouseUp="radListBox_MouseUp">
    <telerik:RadListBox.Effect>
        <DropShadowEffect ShadowDepth="10" Color="Gray" Opacity=".4" Direction="320" RenderingBias="Performance" />
    </telerik:RadListBox.Effect>
</telerik:RadListBox>

The ListBox uses this template:
<DataTemplate x:Key="AutoCompleteListBoxTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Style="{StaticResource AutoCompleteListBoxIcon}" Width="10" Height="10" Margin="0,0,10,0" />
<TextBlock Text="{Binding Name}" Grid.Column="1" HorizontalAlignment="Stretch" />
<TextBlock Text="" Grid.Column="2" HorizontalAlignment="Right" Margin="5,0,5,0" />
</Grid>
</DataTemplate>


I set the ItemsSource in code behind:
private void radRichTextBox_Loaded(object sender, RoutedEventArgs e)
{
    //Set Autocomplete ListBox itemssource
    radListBox.ItemsSource = autoCompleteListItems;
}


The documentation does state the following:
RadListBox has full autocomplete support - while the control is focused, you can type certain keys and the listbox will select the relative match for the currently typed text. 

I'm building a RichTextBox Intellisense application, thus the ListBox is the Intellisense. The application is setup to always send focus back to the RichTextBox so that the user can continue typing.

Is it possible to set the ListBox AutoComplete text in code behind? i.e. when the user types text in the RadRichText box, the text they type is used to set AutoComplete the ListBox.

I've tried setting the TypedText property:
listBox.TypedText = "He";

However this doesn't seem to do anything.

Thank you very much,

Rob



2 Answers, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 10 May 2012, 08:32 AM
Hello,

Thank you for your feedback.

We successfully reproduced this at our side. You can track this issue's status into our PITS here. We will do our best to fix this for one of our future releases.

I have also updated your Telerik points.

Greetings,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Robert
Top achievements
Rank 1
answered on 10 May 2012, 09:39 AM
Hi,

Thanks for letting me know. 

Rob
Tags
ListBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Ivo
Telerik team
Robert
Top achievements
Rank 1
Share this question
or