I have a RadGridView, in the first column is an AutoCompleteBox for searching articles in every row and the other GridViewDataColumn's get filled by the Information of the chosen article in the AutoCompleteBox.
I have build the RadGridView with AutoCompleteBox like this:
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn
x:Name="ArtikelNr"
Header="Artikel-/Materialsuche"
Width="Auto"
MinWidth="150"
IsReadOnly="True"
IsGroupable="True"
IsFilterable="True">
<telerik:GridViewDataColumn.CellStyle>
<Style TargetType="{x:Type telerik:GridViewCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:GridViewCell}">
<telerik:RadAutoCompleteBox x:Name="AutoCompleteBox_ArtikelNr" DropDownItemTemplate="{StaticResource CustomAutoCompleteBoxItemTemplate1}"
ItemsSource="{Binding DataContext.ArtikelAuswahl, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}"
SelectedItem="{Binding RadAutoCompleteBoxArtikel_SelectedItem, Mode=TwoWay}"
SelectionChanged="AutoCompleteBoxArtikel_SelectionChanged"
FilteringBehavior="{StaticResource ArtikelSucheFilteringBehavior}"
DisplayMemberPath="ArtikelNr"
TextSearchMode="Contains"
MaxDropDownHeight="400"
DropDownWidth="1000"
WatermarkContent="Suche..."
HorizontalAlignment="Stretch"
AutoCompleteMode="Suggest"
SelectionMode="Single"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:GridViewDataColumn.CellStyle>
</telerik:GridViewDataColumn>
…
I fill the Columns with Information I seleced in the AutoCompleteBox like this:
private void AutoCompleteBoxArtikel_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
if (currentTabellenDaten != null)
{
//int rowIndex = this.radGridView1.Items.IndexOf(this.radGridView1.SelectedItem);
//rowIndex = rowIndex + 1;
TabellenDaten geladeneTabellenDaten = new TabellenDaten();
bool ok = MainViewModel.TabellenDatenController.LoadTabellenDaten(((Artikel)e.AddedItems[0]).ArtikelNr, geladeneTabellenDaten);
currentTabellenDaten.ArtikelNr = geladeneTabellenDaten.ArtikelNr;
currentTabellenDaten.ArtikelBez1 = geladeneTabellenDaten.ArtikelBez1;
currentTabellenDaten = null;
this.radGridView1.CommitEdit();
geladeneTabellenDaten = null;
}
}
My Problem is, that I can't get the Row index of the Current edited AutoCompleteBox(I tried like in the Code commented out but doesn't work), so when I want to edit a Row that already has some Information (selecting an other article in the AutoCompleteBox) , the new Information should be written in the same Row.
Is it possible with my type of implemetation of the AutoCompleteBox in the RadGridView?
Is there an other or better way to have an AutoCompleteBox in the RadGridview?
I hope you can understand my Problem and I'm sorry for my bad english skills.