0

The class below is the data source for the combo of datagridview:

public class Customer
{
    public int Id { get; set; }

    public string Name { get; set; }

    public string City { get; set; }
}

The next is the data source for the datagridview:

public class Order
{
    public int Id { get; set; }

    public int IdCustomer { get; set; }

    public DateTime RequestDate { get; set; }
}

For simplicity, I will carry them with fixed values, but similar to my real case:

private void Form1_Load(object sender, EventArgs e)
    {
        bdsCustomer.DataSource = new List<Customer>
                                     {
                                         new Customer {Id = 1, Name = "Paulo", City = "City A"},
                                         new Customer {Id = 2, Name = "Tatiane", City = "City B"},
                                         new Customer {Id = 3, Name = "Paulo", City = "City C"},
                                     };

        bdsOrder.DataSource = new List<Order>
                                  {
                                      new Order {Id = 1, IdCustomer = 1, RequestDate = new DateTime(2015, 8, 25)},
                                      new Order {Id = 2, IdCustomer = 2, RequestDate = new DateTime(2015, 8, 26)},
                                      new Order {Id = 3, IdCustomer = 3, RequestDate = new DateTime(2015, 8, 27)}
                                  };


    }

I'll let the field "IdCustomer" in datagridview to display the problem and I'll create a new field with the combo: enter image description here

Notice in the image that the "IdCustomer" field of the first record is correct and presenting the Id 1: enter image description here

Now I will select the other "Paul" with the Id 3 and see what happens to the value of IdCustomer: enter image description here

Even selecting the client with the Id 3, the Id continues 1. You can have 10 clients "Paul", anyone who select the IdCustomer does not change.

What can I do?

I solved the problem, I used the DevExpress grid, is now working perfectly! enter image description here

Paulo Balbino
  • 243
  • 1
  • 14
  • 1
    You just can't have two display items that are the same display. How would the end user know which Paulo to select from the drop down? – LarsTech Aug 27 '15 at 17:52
  • @LarsTech, I really found it strange the possibility, but as I did not think anything about not being able to use duplicate values decided to post to know if there is a solution or if it's a bug, thank you! – Paulo Balbino Aug 27 '15 at 18:03

0 Answers0