Click here to Skip to main content
15,887,285 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
how can i fill the gridlookupedit correctly?. I can not find the error.

What I have tried:

C#
public void CargaGLEVerdadero()
    {
        pcbjEntidades contexto = new pcbjEntidades();
        IList consultaModeloInsumosVerdadera = (from ModeloInsumoes in contexto.ModeloInsumoes
                                                where
                                                  ModeloInsumoes.Activo == true
                                                select new
                                                {
                                                    ModeloInsumoes.NombreModeloInsumo
                                                }).ToList();

        gleNombreModelo.Properties.DataSource = new BindingSource(consultaModeloInsumosVerdadera, "");
    }

C#
public frmAgregarMarca()
    {
        InitializeComponent();
        CargaGLEVerdadero();
    }


RESULT FROM MY GRIDLOOKUPEDIT
http://i.stack.imgur.com/yLJut.png
Posted
Updated 24-Mar-16 7:31am

1 solution

You need to set the .DisplayMember property to "NombreModeloInsumo", otherwise the control treats the elements of the IList as the objects that should be displayed. But the elements of the IList are of the "anonymous type" that you construct with the select new-statement your LINQ-query and the value that should be editable is contained therein in the NombreModeloInsumo-property.

C#
gleNombreModelo.Properties.DataSource = new BindingSource(consultaModeloInsumosVerdadera, "");
gleNombreModelo.Properties.DisplayMember = "NombreModeloInsumo";


There's also a .ValueMember-property which often is used in conjunction with .DisplayMember and might be of interest to you. Take a look at the documentation: Online Documentation - Developer Express Inc.[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900