<telerik:GridViewComboBoxColumn Header="To" DataMemberBinding="{Binding ToWireIns}" ItemsSource="{Binding WireInsCollection}" Width="150" SelectedValueMemberPath="WireInsId" Background="AntiqueWhite" IsComboBoxEditable="True"> <telerik:GridViewComboBoxColumn.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" > <TextBlock Text="{Binding CustodianCode}" Width="50" /> <TextBlock Text="{Binding AccountCode}" Width="40"/> </StackPanel> </DataTemplate> </telerik:GridViewComboBoxColumn.ItemTemplate></telerik:GridViewComboBoxColumn>12 Answers, 1 is accepted
You may set the IsComboBoxEditable property of the column. Thus you will be able to edit the combo box and the autocomplete functionality will be turned on.
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Indeed, it was my mistake as I do not notice the mentioned property set. Please excuse me for that. Still, the autocomplete functionality of the combo box is not to open the drop down and select the item, but rather find it directly in the editable part of it.
Please take a look at this demo and test the feature (you may test it in the first RadComboBox).
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
GridViewComboBoxColumn . I have both controls hooked up simultaneously to make sure all bindings are working.I have attached both pieces of code. Can you help figure out why it won't work in the
GridViewComboBoxColumn Autocomplete Working
<telerik:RadComboBox ItemsSource="{Binding WireInsCollection}" Width="185" Height="50" ItemTemplate="{StaticResource ComboBoxCustomTemplate}" telerik:TextSearch.TextPath="CustodianCode"/>Autocomplete Not Working
<telerik:GridViewComboBoxColumn Header="From" DataMemberBinding="{Binding FromWireIns}" ItemsSource="{Binding WireInsCollection}" Width="185" Background="AntiqueWhite" ItemTemplate="{StaticResource ComboBoxCustomTemplate}" SelectedValueMemberPath="WireInsId" telerik:TextSearch.TextPath="CustodianCode"/>Please take a look at the sample project for a reference. May you check whether it corresponds to your settings and requirements ?
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Using the same settings as the sample project, my GridViewComboBoxColumn does not autocomplete. I see that the version of Telerik.Windows.Controls dll in my project is 2011.2.712.35 whereas the version of Telerik.Windows.Controls dll in your sample project is 2011.2.712.40. Do you think this could be the reason ?
I have tested the project targeting WPF 3.5 with the binaries from 2011.2.712.35. Still, the behavior is the same. I am attaching the updated project. Can you reproduce the issue on this project ?
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Actually, this is the expected behavior. If you do not override the ToString() method, you will get the whole object displayed, while editing. Consequently, you will not able to do the search based on the value of the corresponding property.
Maya
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
I created my own Column type...
public class SearchableComboBoxColumn : GridViewBoundColumnBase{ #region Members public static readonly DependencyProperty DisplayMemberPathProperty = DependencyProperty.Register("DisplayMemberPathValue", typeof(string), typeof(SearchableComboBoxColumn)); public static readonly DependencyProperty ItemSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable<object>), typeof(SearchableComboBoxColumn)); public static readonly DependencyProperty SelectedValueMemberPathProperty = DependencyProperty.Register("SelectedValueMemberPath", typeof(string), typeof(SearchableComboBoxColumn)); #endregion #region Properties /// <summary> /// Gets or sets the display member path. /// </summary> /// <value> /// The display member path. /// </value> public string DisplayMemberPath { get { return (string) GetValue(DisplayMemberPathProperty); } set { SetValue(DisplayMemberPathProperty, value); } } /// <summary> /// Gets or sets the items source. /// </summary> /// <value> /// The items source. /// </value> public IEnumerable<object> ItemsSource { get { return (IEnumerable<object>) GetValue(ItemSourceProperty); } set { SetValue(ItemSourceProperty, value); } } /// <summary> /// Gets or sets the selected value member path. /// </summary> /// <value> /// The selected value member path. /// </value> public string SelectedValueMemberPath { get { return (string) GetValue(SelectedValueMemberPathProperty); } set { SetValue(SelectedValueMemberPathProperty, value); } } #endregion #region Public Methods /// <summary> /// Creates the element for the cell in edit mode. /// </summary> /// <param name="cell"></param> /// <param name="dataItem"></param> /// <returns></returns> public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem) { cell.HorizontalContentAlignment = HorizontalAlignment.Stretch; this.BindingTarget = System.Windows.Controls.Primitives.Selector.SelectedValueProperty; var comboBox = new RadComboBox { HorizontalAlignment = HorizontalAlignment.Stretch, ItemsSource = this.ItemsSource, IsTextSearchEnabled = true, IsTextSearchCaseSensitive = false, StaysOpenOnEdit = true, IsEditable = true, IsFilteringEnabled = true, TextSearchMode = TextSearchMode.Contains, SelectedValuePath = this.SelectedValueMemberPath, DisplayMemberPath = this.DisplayMemberPath, Text = this.GetText(dataItem) }; comboBox.SetBinding(this.BindingTarget, new Binding { Mode = BindingMode.TwoWay, Path = new PropertyPath(this.DataMemberBinding.Path.Path) }); return comboBox; } /// <summary> /// </summary> /// <param name="cell"></param> /// <param name="dataItem"></param> /// <returns></returns> /// <inheritdoc /> public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem) { cell.HorizontalContentAlignment = HorizontalAlignment.Stretch; return new TextBlock { HorizontalAlignment = HorizontalAlignment.Stretch, Text = this.GetText(dataItem) }; } #endregion #region Private Methods /// <summary> /// Gets the text. /// </summary> /// <param name="dataItem">The data item.</param> /// <returns></returns> private string GetText(object dataItem) { Type type = dataItem.GetType(); PropertyInfo property = new List<PropertyInfo>(type.GetProperties()).Single(p => p.Name.Equals(this.DataMemberBinding.Path.Path)); object identifier = property.GetValue(dataItem); object value = this.ItemsSource.SingleOrDefault(x => x.GetType().GetProperty(this.SelectedValueMemberPath).GetValue(x).Equals(identifier)); return value?.GetType().GetProperty(this.DisplayMemberPath).GetValue(value).ToString(); } #endregion}That's great. Thanks a lot for sharing it with the community.
Regards,
Maya
Telerik