Grid View Combo Box Column with suggest mode contains

3 posts, 1 answers
  1. Usman
    Usman avatar
    5 posts
    Member since:
    Sep 2013

    Posted 02 Jul Link to this post

    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. Answer
    Nadya
    Admin
    Nadya avatar
    344 posts

    Posted 06 Jul Link to this post

    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.
  3. Usman
    Usman avatar
    5 posts
    Member since:
    Sep 2013

    Posted 06 Jul in reply to Nadya Link to this post

    Thank you very much Nadya. So nice of you. totally solved my problem. 
Back to Top