ComboBox Text

3 posts, 1 answers
  1. Mehdi
    Mehdi avatar
    9 posts
    Member since:
    Jan 2018

    Posted 10 Jan 2018 Link to this post

    hi

    im using 

    design a radMultiComboBox with 3 column(two column is visible) and one column to select "ValueMember". use the below code for "filtering" :

    1.customerlist.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    2.CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
    3.FilterDescriptor prodName = new FilterDescriptor("FullName", FilterOperator.Contains, "");
    4.compositeFilter.FilterDescriptors.Add(prodName);
    5.compositeFilter.LogicalOperator = FilterLogicalOperator.Or;
    6.this.customerlist.EditorControl.FilterDescriptors.Add(compositeFilter);

     

    every thing work perfectly, but in my project, when user type the name that not in DB, the application show the messagebox and open new form to add item into database.

    private void customerlist_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (!string.IsNullOrEmpty(customerlist.Text))
                    {
                        string name = customerlist.Text;
                        rollback:
                        if (_db.Customer.Any(p => p.FullName.Contains(customerlist.Text.Trim())))
                        {
                            int id = int.Parse(customerlist.SelectedValue.ToString());
                            var result = _db.Customer.First(p => p.CustomerId == id);
                            txttel.Text = result.HomeTel;
                            txtmobile.Text = result.Mobile;
                            txtaddress.Text = result.Address;
                            SendKeys.Send("{tab}");
                            str = null;
                        }
                        else
                        {
                            RadMessageBox.Show(this, "مشتری جدید باید در لیست مشتریان ثبت شود");
     
                            using (FrmAddPerson frm = new FrmAddPerson())
                            {
                                frm.txtfullname.Text = customerlist.Text;
                                frm.radGroupBox1.Enabled = false;
                                frm.radGridView1.Enabled = false;
                                frm.ShowDialog();
                            }
                            cCustomer();
                            customerlist.Text = name;
                            goto rollback;
     
                        }
                    }
                }
            }

    when user press enter, this code should be work, but radmulticolumncombobox.Text property, is null (" "). while must be show what's user typed in combobox.

    for example, in radmulticolumncombobox.Datasource, these exist : john,david,oliver , and user input : jason => radmulticolumncombobox.Text should be = "jason", but it's null.

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3324 posts

    Posted 12 Jan 2018 Link to this post

    Hello, Mehdi,   

    Thank you for writing.  

    The provided code snippet is greatly appreciated. I was able to observe the described behavior. Note that when you type an invalid text (no record exists in the DataSource that matches the filter criteria) if you try to exit the control or press Enter to confirm the value it won't be kept in the editable part because there is no row that matches the text. That is why the RadMultiColumnComboBox.Text is cleared. You can detect the Enter key before the text is cleared. It is necessary to handle the MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.TextBoxControl.PreviewKeyDown event: 
    this.radMultiColumnComboBox1.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.TextBoxControl.PreviewKeyDown += TextBoxControl_PreviewKeyDown;

    private void TextBoxControl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            Console.WriteLine(this.radMultiColumnComboBox1.Text);
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Mehdi
    Mehdi avatar
    9 posts
    Member since:
    Jan 2018

    Posted 12 Jan 2018 Link to this post

    Hi Dess.

    Thank u so much.

    It's working so good.

     

Back to Top