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

ComboBox Text

2 Answers 92 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Mehdi
Top achievements
Rank 1
Mehdi asked on 11 Jan 2018, 12:00 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Jan 2018, 09:08 AM
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.
0
Mehdi
Top achievements
Rank 1
answered on 12 Jan 2018, 02:51 PM

Hi Dess.

Thank u so much.

It's working so good.

 

Tags
MultiColumn ComboBox
Asked by
Mehdi
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Mehdi
Top achievements
Rank 1
Share this question
or