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

Autocomplete logic with 'Contains' instead of 'Starts with' on GridViewComboBoxColumn

1 Answer 103 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Francois
Top achievements
Rank 1
Francois asked on 16 Jun 2011, 02:40 PM
Hi, I'm looking for a way to modify the AutoComplete mechanism to filter using 'Contains' instead of 'Starts with' when the user types.

I've seen this functionality is available on the ASP.NET and WPF controls, but haven't found a way to use it or implement it my own way with the WinForms controls.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 21 Jun 2011, 04:15 PM
Hi Francois,

Thank you for writing.

RadGridView does not have the required functionality built-in. However, it is possible to implement it through customizing the combo-box editor. Please consider the following code sample:

    void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadDropDownListEditor dropDownEditor = this.radGridView1.ActiveEditor as RadDropDownListEditor;
        if (dropDownEditor != null)
        {
            RadDropDownListEditorElement dropDownEditorElement = (RadDropDownListEditorElement)dropDownEditor.EditorElement;
 
            dropDownEditorElement.AutoCompleteMode = AutoCompleteMode.Suggest;
            dropDownEditorElement.AutoCompleteSuggest = new CustomAutoSuggestHelper(dropDownEditorElement);
            dropDownEditorElement.DropDownStyle = RadDropDownStyle.DropDown;
        }
    }
 
public class CustomAutoSuggestHelper : AutoCompleteSuggestHelper
{
    public CustomAutoSuggestHelper(RadDropDownListElement owner)
        : base(owner)
    {
    }
 
    protected override bool DefaultFilter(RadListDataItem item)
    {
        return item.Text.Contains(this.Filter);
    }
}

Hope this helps. Let me know if you have any other questions. 

Kind regards,
Martin Vasilev
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Francois
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or