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

Autocomplete on textbox column

10 Answers 652 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 27 Jan 2014, 09:48 AM
Just wondering, is it possible to implement some autocomplete functionality on gridviewtextboxcolumn.
This will be great advantage.

Regars,
Martin

10 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Jan 2014, 01:33 PM
Hi Martin,

Thank you for writing. 

You can achieve auto complete functionality in a GridViewTextBoxColumn cell by changing the cell editor with a custom one, holding RadAutoCompleteBoxElement. Attached you can find a sample of this. 

I hope this helps. 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Marco
Top achievements
Rank 2
Veteran
answered on 12 Oct 2016, 11:38 AM

Hi,

I'm currently looking for the same thing but it looks like the link to the sample is broken.

Is it possible to update it ?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Oct 2016, 09:28 AM
Hello Marco,

Thank you for writing.  

When I download the project, then remove all references and add them anew by using the DLLs from the installation on my machine, everything works as expected. Please refer to the attached gif file demonstrating the behavior on my end with the latest version.
 
I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Marco
Top achievements
Rank 2
Veteran
answered on 13 Oct 2016, 10:56 AM

Hello Dess,

In fact my problem is about downloading the project files. I get 404 error page when I click on the link (same about your picture file).

I will check it on another computer and network.

Best regards

Marco

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Oct 2016, 11:23 AM
Hello Marco, 

Thank you for writing back. 

I have attached the sample project again. Could you please try to download it now? 

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Marco
Top achievements
Rank 2
Veteran
answered on 13 Oct 2016, 04:48 PM

Hello Dess,

It's always the same on my personnal or work computer. All links give me the same error. 

I attach a picture of the error page.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Oct 2016, 08:19 AM
Hello Marco, 

Thank you for writing back. 

Currently, we are experiencing an issue with the attachments in the public forums. Please excuse us for the inconvenience caused.The problem will be addressed as soon as possible.

You can find below the complete code snippet that the project contains: 
private void Form1_Load(object sender, EventArgs e)
{
    this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
 
    this.radGridView1.DataSource = this.customersBindingSource;
    radGridView1.EditorRequired += radGridView1_EditorRequired;
    radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
    radGridView1.AutoSizeRows = true;
}
 
void radGridView1_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e)
{
    if (radGridView1.CurrentColumn.Name == "Country")
    {
        e.Editor = new MyAutoCompleteEditor();
    }
}
 
void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
    if (e.ActiveEditor is MyAutoCompleteEditor)
    {
        DataTable uniqueCountries = nwindDataSet.Tables[0].DefaultView.ToTable(true, "Country");
        MyAutoCompleteEditor editor = (MyAutoCompleteEditor)e.ActiveEditor;
        RadAutoCompleteBoxElement element = (RadAutoCompleteBoxElement)editor.EditorElement;
        element.Delimiter = ' ';
        element.AutoCompleteDataSource = uniqueCountries;
        element.AutoCompleteDisplayMember = "Country";
        element.AutoCompleteValueMember = "Country";
    }
}

class MyAutoCompleteEditor : RadTextBoxControlEditor
{
    protected override Telerik.WinControls.RadElement CreateEditorElement()
    {
        return new RadAutoCompleteBoxElement();
    }
 
    public override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
    {
        RadAutoCompleteBoxElement element = this.EditorElement as RadAutoCompleteBoxElement;
         
        if (element.IsAutoCompleteDropDownOpen)
        {
            return;
        }
 
        base.OnKeyDown(e);
    }
     
}

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Marco
Top achievements
Rank 2
Veteran
answered on 17 Oct 2016, 08:08 AM

Hello Dess

Thanks for the snippet. I have found all the information I needed to implement this behavior in my project.

Hope that's the issue about the attachments will be resolved soon.

Best regards

Marco

0
Leandro
Top achievements
Rank 1
answered on 08 Sep 2018, 09:03 PM
Hey, did u made a custom autocomplete editor? Because using their solution is not the best, as it does a tokenized items. Can u post your code?
0
Leandro
Top achievements
Rank 1
answered on 08 Sep 2018, 09:33 PM

looking into properties I just found how to make it work like textbox:

 

 private void Grid_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        {
            if (e.Column.Name == "columnname")
            {
                RadTextBoxEditor editor = (RadTextBoxEditor)e.ActiveEditor;
                var element = editor.EditorElement as RadTextBoxEditorElement;
                element.TextBoxItem.TextBoxControl.AutoCompleteMode = AutoCompleteMode.Suggest;
                element.TextBoxItem.TextBoxControl.AutoCompleteCustomSource.AddRange(YourSource);
                element.TextBoxItem.TextBoxControl.AutoCompleteSource = AutoCompleteSource.CustomSource;
            }
        }

 

Just make an extension method and be happy

 

 

Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Marco
Top achievements
Rank 2
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Leandro
Top achievements
Rank 1
Share this question
or