GridViewComboBoxColumn lost value when lost focus.

6 posts, 1 answers
  1. Pam
    Pam avatar
    11 posts
    Member since:
    Feb 2011

    Posted 24 Apr 2011 Link to this post

    Hi, in my gridview i have a GridViewComboBoxColumn, i have filled it with data but when i select a value and i move to another cell, the previous selected value gets lost and it's blank. Any ideas of how to solve this?

    this is my code
    GridViewComboBoxColumn gridComboBox = new GridViewComboBoxColumn();
    gridComboBox.DataMemberBinding = new Binding("ElementoCatalogo");
    gridComboBox.Header = "Afinidad";
    gridComboBox.Width = 200;
    gridComboBox.SelectedValueMemberPath = "ID";
    gridComboBox.DisplayMemberPath = "Descripcion";
    List<ElementoCatalogo> lista = new List<ElementoCatalogo>();
    lista = EnlacesDLL.Logic.CatalogoLogic.seleccionarCatalogo("AFINIDAD");
    gridComboBox.ItemsSource = lista;
    gridCandidaturas.Columns.Add(gridComboBox);
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 25 Apr 2011 Link to this post

    Hello Pam,

    Can you please paste the implementation of the business objects you are binding to - the ones used as a items source for RadGridView and the ones used as items source for the combo .
    I will try to reproduce the problem here and see what went wrong.

    Kind regards,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Pam
    Pam avatar
    11 posts
    Member since:
    Feb 2011

    Posted 25 Apr 2011 Link to this post

    This is my radGridView declaration on XAML:
    <telerik:RadGridView AllowDrop="False" AutoGenerateColumns="False" CanUserDeleteRows="True" CanUserFreezeColumns="True" CanUserInsertRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" IsFilteringAllowed="False" IsScrolling="False" Margin="12,9,6,22" Name="gridCandidaturas" RowDetailsVisibilityMode="Visible" RowIndicatorVisibility="Collapsed" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" ShowGroupPanel="False" telerik:StyleManager.Theme="Office_Silver" Grid.Row="2">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn IsReadOnly="True" DataMemberBinding="{Binding Puesto}" Header="Puesto" HeaderTextAlignment="Center" TextAlignment="Center" Width="200" />
                    <!--<telerik:GridViewComboBoxColumn Name="cboGridAfinidad"  DataMemberBinding="{Binding Afinidad}" Header="Afinidad" HeaderTextAlignment="Center" TextAlignment="Center" Width="200" />-->
                    <!--<telerik:GridViewDataColumn DataMemberBinding="{Binding Comentarios}" Header="Comentarios" HeaderTextAlignment="Center" TextAlignment="Center" Width="100*" />-->
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>


    This is the business object for the gridView
    public class ResultadoCandidatura
        {
            public int CandidaturaID { get; set; }
            public string Candidatura { get; set; }
            public int AfinidadID { get; set; }
            public string Descripcion { get; set; }
            public string Comentarios { get; set; }
        }
     
    And this is for the comboBoxColumn
    public class ElementoCatalogo
        {
            public int ID { get; set; }
            public string Descripcion { get; set; }
            public int TipoID { get; set; }
        }
  5. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 25 Apr 2011 Link to this post

    Hi Pam,

    you need to set properly the the following set of properties of the Combo column , in order to have it working correctly:

    DataMemberBinding ,SelectedValueMemberPath, DisplayMemberPath and ItemsSource.

    This is described in details in this online help article .

    In your code I see only a setting : DataMemberBinding="{Binding Afinidad}" and no Afinidad property on either of your business objects. There is AfinidadID , but no Afinidad.

    Kind regards,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Pam
    Pam avatar
    11 posts
    Member since:
    Feb 2011

    Posted 25 Apr 2011 Link to this post

    Yes, it had a problem with that. After checking the link you post and checking my business objects, it finally worked. Thank you!
  7. nilam
    nilam avatar
    1 posts
    Member since:
    Aug 2016

    Posted 30 Aug Link to this post

    please help for combo box column in WPF data grid after value selection lost value from current cell

    here my code is :

     <dg:DataGridComboBoxColumn  Header="Select" Width="100" x:Name="Tablex"  ItemsSource="{Binding lstTableName1}" 
                      TextBinding="{Binding Tablex}" SelectedValueBinding="{Binding Tablex}"
                                               
                                DisplayMemberPath = "TableName" SelectedValuePath="TableName"/>

     

Back to Top
UI for WPF is Visual Studio 2017 Ready