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

Hot to allow the user to enter a value that is not in the drop down list

11 Answers 567 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Peter Meinl
Top achievements
Rank 1
Peter Meinl asked on 20 Mar 2010, 05:35 PM
I defined an editable RadComboBox with IsEditable="True" IsReadOnly="False"

 

 

 

 

    <Grid> 
        <telerik:RadComboBox Height="23" HorizontalAlignment="Left" Margin="99,136,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="120" IsEditable="True" IsReadOnly="False" /> 
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="52,230,0,0" Name="Button1" VerticalAlignment="Top" Width="75" /> 
    </Grid> 

and added some items in code behind:

    Private Sub ComboBox1_Loaded(...  
        ComboBox1.Items.Add("aaa")  
        ComboBox1.Items.Add("bbb")  
        ComboBox1.Items.Add("ccc")  
    End Sub 

When the user enters a new value in the edit box this value disappears when leaving the RadComboBox to click a button.
The standard WPF ComboBox does not loose the new value.

Hot can I allow the user to enter a value that is not in the drop down list?

11 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 23 Mar 2010, 10:23 AM
Hi Peter,

I suppose that you are using older version of RadComboBox, which contains an already fixed bug. Please, try the latest internal build, it should resolve the problem:
http://www.telerik.com/account/downloads/internal-builds.aspx

All the best,
Valeri Hristov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Tony Drake
Top achievements
Rank 1
answered on 29 Jun 2010, 02:41 PM
Thanks guys - this bug has cost me hours and hours - lesson to me - ask/check the forum when something odd happens!!
0
Brian Thomas
Top achievements
Rank 1
answered on 21 Dec 2010, 06:44 PM
I am currently having the same problem and I'm using the latest build: 2010.3.1220.40. I've also tried using 2010.3.1220.35 but also have the same problem. Because the value is not in the list, it sends a null value to my view model's setter property. If I have values : "55", "56" in the list but want to type "57", how can I get that to be sent to my view model?

Thank You.
0
George
Telerik team
answered on 28 Dec 2010, 09:39 AM
Hi Brian,

Unfortunately, the RadComboBox is not designed to accomplish such scenario. When a user types in the RadComboBox ( in edit mode) the combo only searches for matches in the items collection.

If you want to send the input text to your view model, I would suggest you to find the TextBox control, placed in the RadComboBox( in edit mode ). You could bind the Text property of the TextBox to yourSubJob property in the ViewModel. For example:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    IList<TextBox> textBoxes = this.cboSubJob.ChildrenOfType<TextBox>();
    Binding binding = new Binding("SubJob");
    binding.Mode = BindingMode.TwoWay;
    textBoxes[0].SetBinding(TextBox.TextProperty, binding);        
}

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

Regards,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Hugo
Top achievements
Rank 1
answered on 19 Sep 2011, 08:54 AM
<telerik:GridViewColumn Header="{x:Static res:Resources.ProductCode}">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding ProductCode}"></TextBlock>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                        <telerik:GridViewColumn.CellEditTemplate>
                            <DataTemplate>
                                <telerik:RadComboBox telerik:TextSearch.TextPath="Code" IsEditable="True" ItemTemplate="{StaticResource ComboBoxCustomTemplate}"
                                                     Text="{Binding ProductCode,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                                     SelectedItem="{Binding Product, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.ProductCodes, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}}}" >
                                </telerik:RadComboBox>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellEditTemplate>
                    </telerik:GridViewColumn>
private string _productCode;
 
        public string ProductCode
        {
            get { return _productCode; }
            set
            {
                if (value != null)
                {
                    _productCode = value;
                    RaisePropertyChanged(() => ProductCode);
                }
            }
        }
0
Shreya
Top achievements
Rank 1
answered on 05 Aug 2014, 12:52 PM
Hi ,
I am facing the same problem. Can you please help me how to find this textbox inside radcombobox in mvvm pattern??
0
Shreya
Top achievements
Rank 1
answered on 05 Aug 2014, 12:53 PM

Hi George,
Can you pls help how can I find this textbox using mvvm pattern in wpf. I am also facing same issue.

Thanks
0
Kalin
Telerik team
answered on 07 Aug 2014, 01:19 PM
Hello Shreya,

Could you please share some more details on the exact scenario you need to achieve? RadComboBox exposes Text property which keeps the typed text, so you no longer need to get the TextBox inside. You can simply bind the Text property of the ComboBox to a property in the ViewModel.

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Shreya
Top achievements
Rank 1
answered on 07 Aug 2014, 01:33 PM
Thanks a lot Kalin's for ur reply. I am not getting worked by having any value in combo by setting the binding to Text property. It accepts the value but still shows the combo as red. Might be due to NotifyError = true in xaml. Now can you pls help me how can I customise this error thing as I do not want to show any error for Numeric(Int32)  but want error for any other value like string or special chars.
0
Kalin
Telerik team
answered on 12 Aug 2014, 07:17 AM
Hi Shreya,

What I can suggest you would be to check the ComboBox Validation example from our online demos on the following link:
http://demos.telerik.com/silverlight/#ComboBox/Validation

The example is for Silverlight but you can use the same approach for WPF as well. Check the ViewModel class and the ValidateModel() and ValidateManufacturer() methods which actually do the validation. You can try to implement the same approach and modify the validation methods as needed.

Hope this will help you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Valentin
Top achievements
Rank 1
Iron
answered on 08 Jul 2019, 09:56 AM

Hi Telerik,

 

I'm using this code to implement an editable RadComboBox where it's authorized to write a value which isn't in ItemSource :

Private Sub UserControl_Loaded(sender As Object, e As RoutedEventArgs)
    'Allow not item source content to ReferenceMIR property
    Dim textBoxesRefMir As List(Of TextBox) = Me.cbxRefMIR.ChildrenOfType(Of TextBox)().ToList()
    Dim bindingRefMIR As Binding = New Binding("ReferenceMIR")
    bindingRefMIR.Mode = BindingMode.TwoWay
    textBoxesRefMir(0).SetBinding(TextBox.TextProperty, bindingRefMIR)
End Sub

 

My RadComboBox :

<telerik:RadComboBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Style="{StaticResource StyleEditableComboBox}" ItemsSource="{Binding Source={x:Static viewmodels:Main.Context}, Path=MIRs}" x:Name="cbxRefMIR"  SelectedValuePath="Name" DisplayMemberPath="Name" SelectedValue="{Binding ReferenceMIR, Mode=TwoWay}" />

 

But I have a problem : not all characters are accepted. And when characters are accepted, when I leave the RadComboBox, the text is deleted.

 

Have you got any idea about this behavior ?

 

Thank you.

Tags
ComboBox
Asked by
Peter Meinl
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Tony Drake
Top achievements
Rank 1
Brian Thomas
Top achievements
Rank 1
George
Telerik team
Hugo
Top achievements
Rank 1
Shreya
Top achievements
Rank 1
Kalin
Telerik team
Valentin
Top achievements
Rank 1
Iron
Share this question
or