Wraps a TextBox control in order to display and capture a property of the business object. There are some limitations with using a TextBox for numbers. For greater control of user input with numbers, you should consider using a NumericUpDown control, failing this the appropriate ITextBoxMapperStrategy can be used.
Inheritance: ControlMapper
        /// <summary>
        /// Adds key press event handlers that carry out actions like
        /// limiting the input of certain characters, depending on the type of the
        /// property
        /// </summary>
        /// <param name="mapper">The TextBox mapper</param>
        /// <param name="boProp">The property being mapped</param>
        public void AddKeyPressEventHandler(TextBoxMapper mapper, IBOProp boProp)
        {
            BoProp = boProp;
            var tb = mapper.GetControl() as TextBox;

            if (tb != null)
            {
                tb.KeyPress += KeyPressEventHandler;
                TextBoxControl = tb;
            }
        }
 public void AddUpdateBoPropOnTextChangedHandler(TextBoxMapper mapper, IBOProp boProp)
 {
     BoProp = boProp;
     _mapper = mapper;
     var tb = mapper.GetControl() as TextBox;
     if (tb != null)
     {
         tb.TextChanged += UpdateBoPropWithTextFromTextBox;
         TextBoxControl = tb;
     }
 }
 protected PanelInfo.FieldInfo CreateFieldInfo(string propertyName)
 {
     ILabel label = GetControlFactory().CreateLabel();
     ITextBox tb = GetControlFactory().CreateTextBox();
     IControlMapper controlMapper = new TextBoxMapper(tb, propertyName, false, GetControlFactory());
     GetControlFactory().CreateErrorProvider();
     return new PanelInfo.FieldInfo(propertyName, label, controlMapper);
 }
        public void TestFieldInfo_Constructor()
        {
            //---------------Set up test pack-------------------
            ILabel label = GetControlFactory().CreateLabel();
            string propertyName = TestUtil.GetRandomString();
            ITextBox tb = GetControlFactory().CreateTextBox();
            IControlMapper controlMapper = new TextBoxMapper(tb, propertyName, false, GetControlFactory());
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            PanelInfo.FieldInfo fieldInfo = new PanelInfo.FieldInfo(propertyName, label, controlMapper);

            //---------------Test Result -----------------------

            Assert.AreEqual(propertyName, fieldInfo.PropertyName);
            Assert.AreSame(label, fieldInfo.LabelControl);
            Assert.AreSame(controlMapper, fieldInfo.ControlMapper);
            Assert.AreSame(tb, fieldInfo.InputControl);
        }
 public void Test_MapperStrategy_Returns_Correct_BoProp_WhenChangingBOs()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadClassDefWithIntegerRule();
     MyBO myBo = new MyBO();
     _mapper = new TextBoxMapper(_textBox, "TestProp2", false, GetControlFactory());
     _mapper.BusinessObject = myBo;
     _textBox.Name = "TestTextBox";
     //---------------Assert pre-conditions--------------
     Assert.AreEqual(_mapper.CurrentBOProp(), ((TextBoxMapperStrategyWin)_mapper.TextBoxMapperStrategy).BoProp);
     Assert.AreEqual(_mapper.Control, ((TextBoxMapperStrategyWin)_mapper.TextBoxMapperStrategy).TextBoxControl);
     //---------------Execute Test ----------------------
     ClassDef.ClassDefs.Clear();
     MyBO.LoadDefaultClassDef();
     MyBO myNewBo = new MyBO();
     _mapper.BusinessObject = myNewBo;
     //---------------Test Result -----------------------
     Assert.AreEqual(_mapper.CurrentBOProp(), ((TextBoxMapperStrategyWin)_mapper.TextBoxMapperStrategy).BoProp);
     //---------------Tear down -------------------------
 }
 public void TestDisplayingRelatedProperty()
 {
     SetupClassDefs("MyValue");
     _mapper = new TextBoxMapper(_textBox, "MyRelationship.MyRelatedTestProp", true, GetControlFactory());
     _mapper.BusinessObject = itsMyBo;
     Assert.AreEqual("MyValue", _textBox.Text);
 }
 public void SetupTest()
 {
     _textBox = GetControlFactory().CreateTextBox();
     _mapper = new TextBoxMapper(_textBox,  "ShapeName", false, GetControlFactory());
     _shape = new Shape();
 }