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

Positioning of cursor in "Auto-Complete" Combobox

9 Answers 386 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 06 Dec 2010, 11:00 PM
Hello Telerik team,
    I am dynamically updating my Itemssource as and when the user types the text in the combo-box.

Now,  As I read in the forums, there is a bug in telerik combobox thereby, the text gets cleared as and when you update the items source.

Well, I overcame it by storing it in a string and putting that string back after updating my items source( though it's not elegant and cheap style of coding).

Now my issue is Inorder for the user to have smooth continous typing sequence, I need to place my cursor at the end of the "search text" I place,

For e.g. If my search text is "ab" , I find items starting with "ab", update my items source with matching records and then I place
the search text "ab" inside combo-box.

Now I need to place my cursor at the end of "ab" so that the user will have  a smooth continuous experience. (At present, the cursor points to the begining of text)

Is there any work-around for it? I would say , you can research the MS auto-complete textbox- you might know what I am saying.

Here is my telerik combobox declaration-

 

 

 

<DataTemplate x:Name="CustomItemTemplate">

 

 

 

 

<StackPanel Orientation="Horizontal">

 

 

 

 

<TextBlock Text="{Binding SRCECODE}" Width="50" FontWeight="Bold" />

 

 

 

 

<TextBlock Text=" - " />

 

 

 

 

<TextBlock Text="{Binding SRCEDESC}" />

 

 

 

 

</StackPanel>

 

 

 

 

</DataTemplate>

 

 

 

 

<DataTemplate x:Name="SelectionBoxTemplate">

 

 

 

 

<StackPanel Orientation="Horizontal" >

 

 

 

 

<TextBlock Text="{Binding SRCECODE}" Width="50" FontWeight="Bold" />

 

 

 

 

<TextBlock Text=" - " />

 

 

 

 

<TextBlock Text="{Binding SRCEDESC}" />

 

 

 

 

</StackPanel>

 

 

 

 

</DataTemplate>

 


---------

telerik

 

 

:RadComboBox x:Name="cbSource"

 

 

 

SelectedValue="{Binding srceId, Mode=TwoWay}"

 

 

 

SelectedValuePath="SRCEID"

 

 

 

ItemsSource="{Binding Path=Data}" Width="250"

 

 

 

IsEditable="True" StaysOpenOnEdit="True" Visibility="Visible"

 

 

 

ItemTemplate="{StaticResource CustomItemTemplate}" telerik:TextSearch.TextPath="SRCEDESC"

 

 

 

SelectionBoxTemplate="{StaticResource SelectionBoxTemplate}"

 

 

 

CanAutocompleteSelectItems="False"

 

 

 

OpenDropDownOnFocus="True"

 

 

 

>

 

9 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 10 Dec 2010, 09:16 AM
Hi Rakesh,

I would suggest you to find the TextBox, placed in the RadComboBox when it is in an edit mode. When you have a reference to the TextBox, you could use TextBox.SelectionStart property. 

I hope this helps.

Greetings,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Rakesh
Top achievements
Rank 1
answered on 10 Dec 2010, 02:45 PM
Hello Telerik Team,

Can you please illustrate the above with an example?

I am not sure of the "Textbox" inside a combo-box.

When I did try placing a textbox in Selectionbox Template, it says Textbox isnt supported. Would really appreciate if you can show me an example of it.
 

<telerik:RadComboBox x:Name="cbSource" SelectedValue="{Binding srceId, Mode=TwoWay}"

 

 

SelectedValuePath="SRCEID" ItemsSource="{Binding Path=Data}" Width="250"

 

 

IsEditable="True" StaysOpenOnEdit="True" Visibility="Visible"

 

 

ItemTemplate="{StaticResource CustomItemTemplate}" telerik:TextSearch.TextPath="SRCEDESC"

 

 

 

CanAutocompleteSelectItems="False" OpenDropDownOnFocus="True">

 

 

<telerik:RadComboBox.SelectionBoxTemplate>

 

 

<TextBox Text="{Binding SRCEDESC}" Width="50" x:Name="edText" TextChanged="edText_TextChanged" />        // Error Here

 

 

</telerik:RadComboBox.SelectionBoxTemplate>

 

 

</telerik:RadComboBox>

 

 

Thanks

0
George
Telerik team
answered on 15 Dec 2010, 10:28 AM
Hi Rakesh,

I would suggest you to use RadComboBox.FindChildByType<TextBox>() method in order to get the TextBox, placed in the editable RadComboBox. 

Attached you can find the sample. I hope this helps.

Greetings,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Rakesh
Top achievements
Rank 1
answered on 16 Dec 2010, 05:09 PM
Hello Telerik Team,
    Textbox works great. you guys are doing a great job.

I have an issue in my combobox. I have ItemTemplate and SelectionBox Template. I am also using textsearch.TextPath . It is bound to only one item,

As in my example, item template consists of both code and description (SRCECODE and SRCEDESC). In auto-complete,  it matches with the desc and completes it,

I dnt want to auto-complete, rather auto-select, but instead of showing the Selectionbox Template, it displays only Description (i.e. textsearch.textpath)

It's really eating all of our development time, I would be really happy if you can please find the reason why selectionbox template isnt working. I am doing all these stuff by following your white sheets,

I have attached the xaml and screenshot for your reference.

I am so close to it but no there yet. Please try to reproduce it in ur lab and let me know. Would really appreciate it

Thanks
Rakesh

0
Keith Stephens
Top achievements
Rank 1
answered on 20 Dec 2010, 09:19 PM
Hello Rakesh,

I am also tring to do the same thing. And I too cannot get it working the way I want. So right now I am trying to impliment http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html the silverlight toolkit's autocompletebox control.  This might help you as well.

0
Keith Stephens
Top achievements
Rank 1
answered on 21 Dec 2010, 04:21 PM
One more thing.  I modified the sample codes keyup event.

private void combo_KeyUp(object sender, KeyEventArgs e)
        {
            RadComboBox cbo = (RadComboBox)sender;
           
            if (this.ComboTextBox != null)
            {
                //this.ComboTextBox.SelectionStart = 0;
                this.ComboTextBox.SelectionStart = cbo.Text.Length + 1;
  
            }
        }
This will put the cursor at the end of what you are typing.  The code as is, was typing backwards. Just FYI.
0
Rakesh
Top achievements
Rank 1
answered on 21 Dec 2010, 04:24 PM
Hello Keith,
    Thanks for your post,

I have already achieved the positioning of cursor.

My issues are
 1. Selection Box Template Not working,
2. Disable AutoComplete -just Only Auto Select
3. Display Member Path \ textsearch path issue

So, I am waiting on these guys for an update

Thanks again for posting me back,
Rakesh
0
George
Telerik team
answered on 23 Dec 2010, 09:46 AM
Hi Rakesh,

Straight to the questions:

  1. SelectionBoxTemplate is applied when the RadComboBox is not in editable mode. For more information, please refer to the following link - http://www.telerik.com/help/silverlight/radcombobox-populating-with-data-selectionbox.html
  2. If you want to disable the AutoComplete, I would suggest you to set IsFilteringEnabled="True" . This will enable filtering and disable autocomplete.
  3. The attached TextSearch.Path property specify which value you want to use for AutoComplete and AutoSelect. The DisplayMemberPath property specifies which value you want to see in the Selection Box of the control. For more information, please refer to the following link - http://www.telerik.com/help/silverlight/radcombobox-features-autocomplete.html

Also, there is a good configuration example for the RadComboBox in our online examples - http://demos.telerik.com/silverlight/#ComboBox/Configurator.

I hope this helps. Please do not hesitate to contact us if you require any further information.


Best wishes,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Martin
Top achievements
Rank 1
answered on 15 Apr 2011, 03:44 PM

 

 

@George: You helped me find a solution for my problem with this: I would suggest you to use RadComboBox.FindChildByType<TextBox>() method in order to get the TextBox, placed in the editable RadComboBox. 

My problem was that when combobox lost focus I needed the text to set the selectionStart to the first character. SelectAllTextEvent = "None" did not work. Now on the lostFocus event I'm doing this and it works:

Private
Sub RadComboBox_LostFocus(sender As System.Object, e As System.Windows.RoutedEventArgs)

 

 

 

 

Dim oCombo As Telerik.Windows.Controls.RadComboBox = sender

 

 

 

 

Dim oTextBox As Windows.Controls.TextBox = oCombo.FindChildByType(Of Windows.Controls.TextBox)()

 

 

oTextBox.SelectionStart = 1

 

 

 

End Sub

Now I need help, because I'd like to have ideas on how I could apply this on all my combobox thru out my application.

 

Tags
ComboBox
Asked by
Rakesh
Top achievements
Rank 1
Answers by
George
Telerik team
Rakesh
Top achievements
Rank 1
Keith Stephens
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Share this question
or