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

Selection of first element

2 Answers 134 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 15 Dec 2008, 06:07 PM
I read the previous post on this problem. In certain situations I am still having trouble selecting the first element in the combo box.

RadComboBox version 2008.3.1117.1020
I have a data template with two columns.
I have tried FilteringMode = StartsWith or Contains.

If I type in a value that is not in the drop down then I display a message and clear the combo text. Then if I try to select the first item it won't select. The second item will. After selecting the second item then I can select the first item.

  <DataTemplate x:Key="test_getFEFPCodesResultTemplate">
   <Grid Margin="0,0,0,0" Width="150">
    <Grid.ColumnDefinitions>
     <ColumnDefinition Width="40"/>
     <ColumnDefinition Width="100"/>
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Row="0" Text="{Binding Path=Code}" />
    <TextBlock Grid.Row="0" Grid.Column="1" Foreground="Blue" Text="{Binding Path=Description}" />
   </Grid>
  </DataTemplate>

<telerikInput:RadComboBox ItemsSource="{Binding Mode=OneWay}" IsEditable="True" telerik:TextSearch.TextPath="Code" Height="20" MinHeight="20" Width="52" FontSize="10" IsEnabled="True" Background="#FF000000" x:Name="cmbFEFP" ItemTemplate="{StaticResource test_getFEFPCodesResultTemplate}" SelectedIndex="-1" Canvas.Left="6.739" Canvas.Top="118" IsReadOnly="False" FilteringMode="Contains">

        <telerikInput:RadComboBox.DataContext>
         <CatalogDemo_ServiceReference1:test_getCatalogFEFPCodesResult/>
        </telerikInput:RadComboBox.DataContext>

Here is the data validation code in the lost focus event. If you know of an easier way to do the validation then please point me in the right direction.

 

Private Sub cmbFEFP_LostFocus(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles cmbFEFP.LostFocus

 

 


If
cmbFEFP.Text = "" Then

 

    cmbFEFP.SelectedIndex = -1

 

    Exit Sub

 

 

End If

 

 


Dim
found As Boolean = False

 

 

Dim fefpCode As ServiceReference1.test_getCatalogFEFPCodesResult

 

 

For index = 0 To cmbFEFP.Items.Count - 1

 

    fefpCode = cmbFEFP.Items(index)

 

    If fefpCode.Code = cmbFEFP.Text Then

 

        found =

True

 

 

        Exit For

 

 

    End If

 

 

Next

 

 


If
Not found Then

 

    RadWindow.Alert(

"This item not in list.")

 

    cmbFEFP.SelectedIndex = -1

    cmbFEFP.Text =

""

 

 

End If

 

 


End
Sub

 


Thanks
 

2 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 18 Dec 2008, 04:20 PM
Hello Michael,

This problem is related to a bug in RadComboBox. Unfortunately I was unable to fix it on time and include it in the today's service pack. As a quick workaround I would suggest setting the Text property of RadComboBox to " " (space), or any other string that is not in the list of the allowed values, instead of "" (string.Empty) when the item is invalid. Please, let me know if this works for you.

We will do our best to provide a public fix in the beginning of the next year. Your points have been updated.

Best wishes,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 18 Dec 2008, 07:04 PM
Thanks Valeri

A few minutes ago I was able to fix the problem. I set the Selected Index to -1 instead of the default 0 and then I was able to select the first item in the list. Maybe I missed that in the previous message on this problem. I found the problem while trying to fix a RadTab problem. I will leave a message in the Tab forum.

Thanks again.

Michael
Tags
ComboBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or