Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Firstly, the code you propose won't even compile - you are missing capitalisation in one area and a semi-colon at the end of the last line (and not a build issue, but I believe to display correctly you want the white space after the last name, not before). Secondly, should you amend it to do so, then there is no apparent reason for this not to display the members. Are you sure the return value of <code>GetEmployees</code> contains at least on element?</p> <p>Consider the following:</p> <p>Our employee type...</p> <pre><code>public class Employee { public Employee() { } public Employee(int id, string firstName, string lastName) { EmployeeID = id; FirstName = firstName; LastName = lastName; } public int EmployeeID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } </code></pre> <p>And within the load event of our form...</p> <pre><code>private void myForm_Load(object sender, EventArgs e) { var employeeA = new Employee(28, "Charlie", "Brown"); var employeeB = new Employee(42, "Familiar", "Stranger"); var employees = new List&lt;Employee&gt;(); employees.Add(employeeA); employees.Add(employeeB); var myDataGridView = new DataGridView(); var myDataGridComboBoxColumn = new DataGridViewComboBoxColumn(); myDataGridComboBoxColumn.HeaderText = "Employee"; myDataGridComboBoxColumn.ValueMember = "ID"; myDataGridComboBoxColumn.DisplayMember = "Name"; myDataGridComboBoxColumn.DataSource = employees.Select(employee =&gt; new { Name = employee.LastName + ", " + employee.FirstName, ID = employee.EmployeeID }).ToList(); myDataGridView.Columns.Insert(0, myDataGridComboBoxColumn); Controls.Add(myDataGridView); myDataGridView.Dock = DockStyle.Fill; } </code></pre> <p>The result is absolute: the expected elements appear in the drop down box. Give it a go, and manoeuvre your way to rid your build errors to maybe, seemingly, magically proceed from this point - didn't you notice them? Note sure how you managed to 'see' anything.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload