Tuesday, 15 July 2014

c# - How do I bind a DataGridViewComboBoxColumn to the list property of the parent row's bound object? -


Text after "

Looking at the following sections:

  public class shirt {public string description {find; Set; } Public listing & lt; Color & gt; Color options {get; Set; } Public Tissue Colloid (Received; Set; }} Public square color {public id id {get; Set; } Public string label {get; Set; }}  

Why can not I get to show up in the DataGridView using the following code

  from the list & lt ;? Shirt & gt; FoundShirts = _dbShirtRepo.GetShirts (); Var name column = new datagrid view text box column (); NameColumn.DataPropertyName = "description"; NameColumn.HeaderText = "description"; Var color contact = new datagridviewcombobox column (); Color Selective Column Date property name = "color option"; Select Color from the Choose Column Displaymilk = "label"; Color Selective Column Value = "id"; DataGridView1.Columns.Add (nameColumn); DataGridView1.Columns.Add (colorSelectColumn); DataGridView1.DataSource = foundShirts; Try something like this:  
    

Private Zero DataGridView1_CellClick (Object Sender, DataGridViewCellEventArgs e) {if (e.ColumnIndex == 1) {DataGridViewComboBoxCell combo = this.dataGridView1 [1, e.RowIndex] DataGridViewComboBoxCell; Combo.DataSource = ((Shirt) DataGrid View1.Rows [e.RowIndex]. DataBoundItem) .ColorOptions; }}

As you can see, you have to provide DataSource per request because you receive only one time

You can improve the solution given above, but the concept is the same:

  • The user clicks, hover or otherwise "activates
  • This is a chance to open the user before setting the combo code

  • The user is not aware of any fraud running and you can provide different options for each person line.

    Note:. I do not believe 100% of operates DataGridViewComboBoxCell , it is entirely possible that it caches and continues its data sources, but depending on it First uses some experiment.


No comments:

Post a Comment