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

11 posts, 1 answers
  1. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 20 Mar 2010 Link to this post

    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?

  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 23 Mar 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tony Drake
    Tony Drake avatar
    3 posts
    Member since:
    Aug 2009

    Posted 29 Jun 2010 Link to this post

    Thanks guys - this bug has cost me hours and hours - lesson to me - ask/check the forum when something odd happens!!
  5. Brian Thomas
    Brian Thomas avatar
    7 posts
    Member since:
    Jul 2009

    Posted 21 Dec 2010 Link to this post

    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.
  6. George
    Admin
    George avatar
    1332 posts

    Posted 28 Dec 2010 Link to this post

    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
  7. Hugo
    Hugo avatar
    2 posts
    Member since:
    Sep 2011

    Posted 19 Sep 2011 Link to this post

    <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);
                    }
                }
            }
  8. Shreya
    Shreya avatar
    18 posts
    Member since:
    Aug 2014

    Posted 05 Aug 2014 in reply to Valeri Hristov Link to this post

    Hi ,
    I am facing the same problem. Can you please help me how to find this textbox inside radcombobox in mvvm pattern??
  9. Shreya
    Shreya avatar
    18 posts
    Member since:
    Aug 2014

    Posted 05 Aug 2014 in reply to George Link to this post


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

    Thanks
  10. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 07 Aug 2014 Link to this post

    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.
     
  11. Shreya
    Shreya avatar
    18 posts
    Member since:
    Aug 2014

    Posted 07 Aug 2014 in reply to Kalin Link to this post

    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.
  12. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 12 Aug 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready