/// <summary>
        /// Constructs a <see cref="RelationshipComboBoxMapper"/> with the <paramref name="comboBox"/>
        ///  <paramref name="relationshipName"/>
        /// </summary>
        /// <param name="comboBox">The combo box that is being mapped to</param>
        /// <param name="relationshipName">The name of the relation that is being mapped to</param>
        /// <param name="isReadOnly">Whether the Combo box can be used to edit from or whether it is only viewable</param>
        /// <param name="controlFactory">A control factory that is used to create control mappers etc</param>
        public RelationshipComboBoxMapper
            (IComboBox comboBox, string relationshipName, bool isReadOnly, IControlFactory controlFactory)
        {
            if (comboBox == null)
            {
                throw new ArgumentNullException("comboBox");
            }
            if (relationshipName == null)
            {
                throw new ArgumentNullException("relationshipName");
            }
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }

            IsReadOnly            = isReadOnly;
            ControlFactory        = controlFactory;
            Control               = comboBox;
            RelationshipName      = relationshipName;
            _boRelationshipMapper = new BORelationshipMapper(relationshipName);
            _boRelationshipMapper.RelationshipChanged += (sender, e) => OnMappedRelationshipChanged();

            _mapperStrategy = ControlFactory.CreateLookupComboBoxDefaultMapperStrategy();
            _mapperStrategy.AddHandlers(this);
            UpdateIsEditable();
            _comboBoxCollectionSelector = new ComboBoxCollectionSelector(comboBox, controlFactory, false)
            {
                PreserveSelectedItem = true
            };
            this.IncludeBlankItem = true;
        }
예제 #2
0
 /// <summary>
 /// Constructor to initialise the mapper
 /// </summary>
 /// <param name="cbx">The ComboBox to map</param>
 /// <param name="propName">The property name</param>
 /// <param name="isReadOnly">Whether this control is read only</param>
 /// <param name="factory">The control factory to be used when creating the controlMapperStrategy</param>
 public CollectionComboBoxMapper(IComboBox cbx, string propName, bool isReadOnly, IControlFactory factory)
     : base(cbx, propName, isReadOnly, factory)
 {
     _comboBox       = cbx;
     _mapperStrategy = factory.CreateLookupComboBoxDefaultMapperStrategy();
     _mapperStrategy.AddHandlers(this);
     _comboBoxCollectionSelector = new ComboBoxCollectionSelector(cbx, factory, false);
     _comboBoxCollectionSelector.PreserveSelectedItem = true;
 }