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

GridViewComboBoxColumn: How can I show the correct Item?

1 Answer 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andi
Top achievements
Rank 2
Andi asked on 20 Jan 2011, 02:21 PM
Hi there,

I have in my Grid a GridViewComboBoxColumn and want to show there the Name of a type from the table which is shown in the grid.

This is the column:
<telerik:GridViewComboBoxColumn Header="Typ" IsFilterable="False" IsGroupable="False" IsSortable="False" ShowDistinctFilters="False" UniqueName="Typ" DataMemberBinding="{Binding Typ}" />

This is how I fill the Names into the Combobox:

private void FillTypItems()
    {
      List<TypItem> TypListe = new List<TypItem>();
      TypItem _TypItem = new TypItem();
 
      _TypItem.Typ = 1;
      _TypItem.TypText = "Ganzzahl";
      TypListe.Add(_TypItem);
 
      _TypItem = new TypItem();
      _TypItem.Typ = 2;
      _TypItem.TypText = "Dezimalzahl";
      TypListe.Add(_TypItem);
 
      _TypItem = new TypItem();
      _TypItem.Typ = 3;
      _TypItem.TypText = "Zeichenkette";
      TypListe.Add(_TypItem);
 
      _TypItem = new TypItem();
      _TypItem.Typ = 5;
      _TypItem.TypText = "Logisch";
      TypListe.Add(_TypItem);
 
      ((GridViewComboBoxColumn)this.rgvUebergabeparameter.Columns["Typ"]).DisplayMemberPath = "TypText";
      ((GridViewComboBoxColumn)this.rgvUebergabeparameter.Columns["Typ"]).ItemsSource = TypListe;
 
    }

And this is the DataItem for the TypeNames (TypText):
public class TypItem
  {
    int _Typ;
    public int Typ
    {
      get
      {
        return _Typ;
      }
      set
      {
        _Typ = value;
      }
    }
 
    string _TypText;
    public string TypText
    {
      get
      {
        return _TypText;
      }
      set
      {
        _TypText = value;
      }
    }
  }

The Combobox is filled correctly, but the Item to the number from table, will not be shown.
What do I have done wrong?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 20 Jan 2011, 02:56 PM
Hello Andi,

You need to set the SelectedValueMemberPath property of the GridViewComboBoxColumn. In your case, I believe it should be -  Typ.

Kind regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Andi
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or