private void cmdPrincipalRole_SelectedIndexChanged(object sender, EventArgs e) { AssociationEnd principal = null; AssociationEnd dependent = null; if (cmdPrincipalRole.SelectedItem == _roleListItems[_end1]) { principal = _end1; dependent = _end2; } else if (cmdPrincipalRole.SelectedItem == _roleListItems[_end2]) { principal = _end2; dependent = _end1; } if (principal == _principal) { return; // no change } // remember new choice _principal = principal; _dependent = dependent; if (_dependent == null) { txtDependentRole.Text = string.Empty; } else { txtDependentRole.Text = _dependent.Role.Value; } // clear our lists listMappings.Items.Clear(); _mappingListItems.Clear(); cmbDependentKey.Items.Clear(); _dependentListItems.Clear(); // user might have chosen the blank row if (_principal != null && _dependent != null) { PopulateMappingListItems(); PopulateListView(); listMappings.Enabled = true; // load dependent role keys into the combo box if (_dependent.Type.Target != null) { cmbDependentKey.Items.Add(_blankDependentKeyListItem); foreach (var key in GetMappableDependentProperties()) { var item = new KeyListItem(key.NormalizedName); _dependentListItems.Add(key.NormalizedName, item); cmbDependentKey.Items.Add(item); } // in the SSDL, ref constraints can be to non-key columns if (_association.EntityModel.IsCSDL == false) { foreach (var prop in _dependent.Type.Target.Properties()) { if (prop.IsKeyProperty) { continue; } var item = new KeyListItem(prop.NormalizedName); _dependentListItems.Add(prop.NormalizedName, item); cmbDependentKey.Items.Add(item); } } } cmbDependentKey.Enabled = true; // select the first row if (listMappings.Items.Count > 0) { listMappings.Focus(); var lvItem = listMappings.Items[0]; lvItem.Selected = true; ShowDependencyKeyComboBox(lvItem); } } else { listMappings.Enabled = false; cmbDependentKey.Enabled = false; ChangeDependencyKeyComboBoxVisibility(false); } }