Esempio n. 1
0
        /// <ChangeLog>
        /// <Create Datum="07.11.2020" Entwickler="DA" />
        /// </ChangeLog>
        /// <summary>Creates the Binding</summary>
        /// <param name="propertyName">the properties name in the dataobject</param>
        /// <param name="isCurrency">is this a currency-value (for formatting purposes)</param>
        public Binding CreateBinding(string propertyName, bool isCurrency = false)
        {
            PropertyInfo pi     = ReflectoringCache.GetPropertyInfo(typeof(T), propertyName);
            Binding      retval = null;

            if ((pi != null) &&
                (Nullable.GetUnderlyingType(pi.PropertyType) != null))
            {
                retval = new Binding("Text", _dataSource, propertyName, true, DataSourceUpdateMode.OnPropertyChanged, string.Empty);
            }
            else
            {
                retval = new Binding("Text", _dataSource, propertyName);
            }
            if (isCurrency)
            {
                retval.FormatString = "C";
            }
            return(retval);
        }
Esempio n. 2
0
        /// <ChangeLog>
        /// <Create Datum="07.11.2020" Entwickler="DA" />
        /// </ChangeLog>
        /// <summary>Creates the Binding</summary>
        /// <param name="propertyName">the properties name in the dataobject</param>
        /// <param name="control">the Control to which the property should bound to</param>
        /// <param name="isCurrency">is this a currency-value (for formatting purposes)</param>
        public void CreateBinding(string propertyName, Control control, bool isCurrency = false)
        {
            string controlsPropertyName = FindControlsPropertyName(control);

            if (controlsPropertyName != null)
            {
                PropertyInfo pi      = ReflectoringCache.GetPropertyInfo(typeof(T), propertyName);
                Binding      binding = null;
                if ((pi != null) &&
                    (Nullable.GetUnderlyingType(pi.PropertyType) != null))
                {
                    binding = new Binding(controlsPropertyName, _dataSource, propertyName, true, DataSourceUpdateMode.OnPropertyChanged, string.Empty);
                }
                else
                {
                    binding = new Binding(controlsPropertyName, _dataSource, propertyName);
                }
                if (isCurrency)
                {
                    binding.FormatString = "C";
                }
                control.DataBindings.Add(binding);
            }
        }