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