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

Grid View Combo Box Column with suggest mode contains

2 Answers 274 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Usman
Top achievements
Rank 2
Usman asked on 02 Jul 2020, 06:19 AM

Hello, i need to change the suggest mode of GridViewComboBoxColumn to SuggestMode.Contains. just like we can do it on dropdown control, how can i dot it. 
i am using winforms q2 2014 sp1 version controls. 
also sharing snippet of my code.

var column= new GridViewComboBoxColumn
                {
                    DataSource = ClsProducts.GetActiveProducts(),
                    DisplayMember = "ProductName",
                    ValueMember = "ProductID",
                    Width = 280,
                    HeaderText = "Product",
                    Name = "ColProduct",
                    DropDownStyle = RadDropDownStyle.DropDown,
                    AutoCompleteMode = AutoCompleteMode.SuggestAppend
                };
                dgvTrade.Columns.Insert(1, column);

thanks..

2 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 06 Jul 2020, 01:43 PM

Hello, Usman,

In order to set the AutoCompleteSuggest mode to Contains in GridViewComboBoxColumn you should handle the CellEditorInitialized event as follows:

public RadForm1()
{
    InitializeComponent();
    GridViewComboBoxColumn customerColumn = new GridViewComboBoxColumn("Categories");
    customerColumn.DataSource = this.categoriesBindingSource;
    customerColumn.ValueMember = "CategoryID";
    customerColumn.DisplayMember = "CategoryName";
    customerColumn.FieldName = "CategoryID";
    customerColumn.AutoCompleteMode = AutoCompleteMode.Suggest;
    this.radGridView1.Columns.Add(customerColumn);
    this.radGridView1.CellEditorInitialized += this.RadGridView1_CellEditorInitialized;
}

private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
    if (editor != null)
    {
        RadDropDownListEditorElement el = editor.EditorElement as RadDropDownListEditorElement;
        el.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
        el.AutoCompleteMode = AutoCompleteMode.Suggest;
        el.AutoCompleteSuggest.SuggestMode = SuggestMode.Contains;
    }
}

More information you can find here: 
https://docs.telerik.com/devtools/winforms/controls/gridview/columns/column-types/gridviewcomboboxcolumn
https://docs.telerik.com/devtools/winforms/controls/gridview/editors/default-editors

I hope this helps. Let me know if you have other questions.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Usman
Top achievements
Rank 2
answered on 06 Jul 2020, 03:47 PM
Thank you very much Nadya. So nice of you. totally solved my problem. 
Tags
GridView
Asked by
Usman
Top achievements
Rank 2
Answers by
Nadya | Tech Support Engineer
Telerik team
Usman
Top achievements
Rank 2
Share this question
or