public ControlBindingsCollection(IBindableComponent control)
        {
            bindable_component = control;
            //control = control as Widget;

            default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
        }
		internal ControlBindingsCollection (Control control) {
			this.control = control;
#if NET_2_0
			bindable_component = control as IBindableComponent;
			default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
#endif
		}
 public Binding Add(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode, object nullValue, string formatString, IFormatProvider formatInfo)
 {
     if (dataSource == null)
     {
         throw new ArgumentNullException("dataSource");
     }
     Binding binding = new Binding(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, formatInfo);
     this.Add(binding);
     return binding;
 }
Beispiel #4
0
		public Binding (string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
		{
			property_name = propertyName;
			data_source = dataSource;
			data_member = dataMember;
			binding_member_info = new BindingMemberInfo (dataMember);
			datasource_update_mode = dataSourceUpdateMode;
			null_value = nullValue;
			format_string = formatString;
			format_info = formatInfo;
		}
Beispiel #5
0
		public static void BindField(Control control, string propertyName, object dataSource, string dataMember, DataSourceUpdateMode dataSourceUpdateMode)
		{
			for (int i = control.DataBindings.Count - 1; i >= 0; i--)
			{
				Binding bd = control.DataBindings[i];
				if (bd.PropertyName == propertyName)
				{
					control.DataBindings.Remove(bd);
				}
			}
			if (dataSource != null)
				control.DataBindings.Add(propertyName, dataSource, dataMember).DataSourceUpdateMode = dataSourceUpdateMode;
		}
        //0200001e SharedBrowserSessionExperiment.TheBrowserTab
        //script: error JSC1000: Missing Script Attribute? Native constructor was invoked, please implement [System.Windows.Forms.Binding..ctor(System.String, System.Object, System.String, System.Boolean)]
        // X:\jsc.svn\examples\javascript\p2p\SharedBrowserSessionExperiment\SharedBrowserSessionExperiment\TheBrowserTab.cs

        public __Binding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode)
        {
            // X:\jsc.svn\examples\javascript\forms\test\TestWebBrowserOneWayDataBinding\TestWebBrowserOneWayDataBinding\ApplicationControl.Designer.cs
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201404/20140412

            this.DataSource = dataSource;


            this.DataMember = dataMember;
            this.PropertyName = propertyName;

            this.FormattingEnabled = formattingEnabled;
            this.DataSourceUpdateMode = dataSourceUpdateMode;
        }
Beispiel #7
0
    public void Bind(object model_, string propertyOnModel_, Validators.IValidator validator_, DataSourceUpdateMode mode_=DataSourceUpdateMode.OnPropertyChanged)
    {
      var binding = new System.Windows.Forms.Binding("Text", model_, propertyOnModel_, validator_ != null,
        mode_);

      if (validator_ != null)
      {
        binding.Parse+=new ConvertEventHandler(validator_.Parse);
        binding.Format+=new ConvertEventHandler(validator_.Format);
      }

      if (DataBindings["Text"] != null)
        DataBindings.Remove(DataBindings["Text"]);
      DataBindings.Add(binding);
    }
Beispiel #8
0
		public Binding (string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString)
			: this (propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString, null)
		{
		}
Beispiel #9
0
 private void txtRut_TextChanged(object sender, EventArgs e)
 {
     DataSourceUpdateMode ds = new DataSourceUpdateMode();
 }
Beispiel #10
0
 /// <include file='doc\ControlBindingsCollection.uex' path='docs/doc[@for="ControlBindingsCollection.Add3"]/*' />
 public Binding Add(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode, object nullValue)
 {
     return(Add(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, String.Empty, null));
 }
 protected virtual void BindProperties(DevExpress.XtraBars.BarItem target, string targetProperty, string sourceProperty, DataSourceUpdateMode updateMode)
 {
     target.DataBindings.Add(targetProperty, Controller, sourceProperty, true, updateMode);
 }
 public static void AddBinding <TControl, TViewModel, TViewModelProperty>(this TControl control, Expression <Func <TControl, TViewModelProperty> > controlPropertyExpression,
                                                                          TViewModel viewModel, Expression <Func <TViewModel, TViewModelProperty> > viewModelPropertyExpression, DataSourceUpdateMode dataSourceUpdateMode)
     where TControl : Control
 {
     control.DataBindings.Add(GetPropertyName(controlPropertyExpression), viewModel,
                              GetPropertyName(viewModelPropertyExpression), false, dataSourceUpdateMode);
 }
Beispiel #13
0
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")]               // 'formatString' is an appropriate name, since its a string passed to the Format method
        public Binding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
        {
            this.bindToObject = new BindToObject(this, dataSource, dataMember);

            this.propertyName         = propertyName;
            this.formattingEnabled    = formattingEnabled;
            this.formatString         = formatString;
            this.nullValue            = nullValue;
            this.formatInfo           = formatInfo;
            this.formattingEnabled    = formattingEnabled;
            this.dataSourceUpdateMode = dataSourceUpdateMode;

            CheckBinding();
        }
		public Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode,
			object nullValue, string formatString, IFormatProvider formatInfo)
		{
			if (dataSource == null)
				throw new ArgumentNullException ("dataSource");

			Binding res = new Binding (propertyName, dataSource, dataMember);
			res.FormattingEnabled = formattingEnabled;
			res.DataSourceUpdateMode = updateMode;
			res.NullValue = nullValue;
			res.FormatString = formatString;
			res.FormatInfo = formatInfo;

			Add (res);
			return res;
		}
Beispiel #15
0
 /// <summary>
 /// 对控件进行数据绑定.
 /// </summary>
 /// <param name="控件">要绑定的控件</param>
 /// <param name="控件属性">要绑定的控件属性</param>
 /// <param name="对象">绑定的目标对象</param>
 /// <param name="对象属性">要绑定的对象属性</param>
 /// <param name="格式化规则">格式化规则,如格式化日期的规则"yyyy年M月d日 HH:mm:ss"</param>
 /// <param name="数据源更新模式">指示数据源何时进行同步更新</param>
 public static void 数据绑定(Control 控件, string 控件属性, object 对象, string 对象属性, string 格式化规则, DataSourceUpdateMode 数据源更新模式)
 {
     控件.DataBindings.Clear();
     控件.DataBindings.Add(控件属性, 对象, 对象属性, true, 数据源更新模式);
     控件.DataBindings[0].FormatString = 格式化规则;
 }
Beispiel #16
0
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] // 'formatString' is an appropriate name, since its a string passed to the Format method
        public Binding(string propertyName, Object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo) {
            this.bindToObject = new BindToObject(this, dataSource, dataMember);

            this.propertyName = propertyName;
            this.formattingEnabled = formattingEnabled;
            this.formatString = formatString;
            this.nullValue = nullValue;
            this.formatInfo = formatInfo;
            this.formattingEnabled = formattingEnabled;
            this.dataSourceUpdateMode = dataSourceUpdateMode;

            CheckBinding();
        }
 internal ControlBindingsCollection(Widget control)
 {
     bindable_component = control as IBindableComponent;
     default_datasource_update_mode = DataSourceUpdateMode.OnValidation;
 }
 public Binding Add(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode)
 {
     return this.Add(propertyName, dataSource, dataMember, formattingEnabled, updateMode, null, string.Empty, null);
 }
 public CustomBinding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
     : base(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString, formatInfo)
 {
 }
Beispiel #20
0
 public Binding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode)
     : base(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode)
 {
 }
Beispiel #21
0
        protected void Bind(IBindableComponent component, string propertyName, string dataMember, IValueConverter converter = null, DataSourceUpdateMode dataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged)
        {
            var binding = new CustomBinding(propertyName, this, dataMember, converter)
            {
                DataSourceUpdateMode = dataSourceUpdateMode,
                ControlUpdateMode    = ControlUpdateMode.OnPropertyChanged
            };

            component.DataBindings.Add(binding);
            _bindings[dataMember] = binding;
        }
 public ConvertableDataBinding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue)
     : base(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue)
 {
 }
Beispiel #23
0
 /// <include file='doc\ListBinding.uex' path='docs/doc[@for="Binding.Binding2"]/*' />
 public Binding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode) : this(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, null, string.Empty, null)
 {
 }
 public ConvertableDataBinding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
     : base(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString, formatInfo)
 {
 }
	public Binding Add(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode, object nullValue, string formatString, System.IFormatProvider formatInfo) {}
Beispiel #26
0
        public IndicationBinding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode)
            : base(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode)
        {
            int         formatTimes = 0;
            IComparable lastValue   = null;

            Format += delegate(object sender, ConvertEventArgs e)
            {
                //升降红绿显示
                IComparable value = (IComparable)e.Value;
                if (value == null)
                {
                    return;
                }

                if (lastValue == null)
                {
                    lastValue = (IComparable)e.Value;
                    return;
                }

                // format数次以后,才开始处理。目的:一开始有不合理,不完整数据。
                if (formatTimes < 3)
                {
                    formatTimes++;
                    lastValue = (IComparable)e.Value;
                    return;
                }

                int compRes = value.CompareTo(lastValue);
                if (compRes > 0)
                {
                    Control.ForeColor = Color.Red;
                }
                else if (compRes < 0)
                {
                    Control.ForeColor = Color.Green;
                }
                else
                {
                    //TODO 有可能需要隐掉。原因:marketdata的tick太快的时候,多数价格是不变化的。因此一直看到黑色。
                    Control.ForeColor = Color.Black;
                }

                lastValue = (IComparable)e.Value;
            };
        }
 public Schema(IBindableComponent targetControl, string targetField, object dataStore, string dataField, DataSourceUpdateMode updateMode = DataSourceUpdateMode.OnPropertyChanged, ConvertEventHandler formatter = null, ConvertEventHandler parser = null)
 {
     TargetControl = targetControl; TargetField = targetField; DataStore = dataStore; DataField = dataField; UpdateMode = updateMode; Parser = parser; Formatter = formatter;
 }
 /// <summary>
 /// Bind Control property to object property. Usage: control.Bind(a=>a.ControlProperty, model, a=>a.ModelProperty.ModelSubProperty)
 /// </summary>
 /// <typeparam name="TControl">Control type(don't specify manually)</typeparam>
 /// <typeparam name="TProperty">Control target property type (don't specify manually)</typeparam>
 /// <typeparam name="TModel">Model type (don't specify manually)</typeparam>
 /// <typeparam name="TBind">Model property type  (don't specify manually)</typeparam>
 /// <param name="control">Control to apply the binding to</param>
 /// <param name="property">Control property expression</param>
 /// <param name="model">Binding model object</param>
 /// <param name="bind">Binding propery expression</param>
 /// <param name="formattingEnabled">Enable formatting</param>
 /// <param name="updateMode">Update mode</param>
 /// <returns></returns>
 public static Binding Bind <TControl, TProperty, TModel, TBind>(this TControl control, Expression <Func <TControl, TProperty> > property, TModel model, Expression <Func <TModel, TBind> > bind, bool formattingEnabled = false, DataSourceUpdateMode updateMode = DataSourceUpdateMode.OnPropertyChanged)
     where TControl : IBindableComponent
 => BindInternal(control, property, model, bind, formattingEnabled, updateMode);
Beispiel #29
0
        /// <include file='doc\ControlBindingsCollection.uex' path='docs/doc[@for="ControlBindingsCollection.Add4"]/*' />
        public Binding Add(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode, object nullValue, string formatString, IFormatProvider formatInfo)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource));
            }
            Binding binding = new Binding(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, formatInfo);

            Add(binding);
            return(binding);
        }
Beispiel #30
0
 /// <summary>
 /// 设置数据源更新方式。
 /// </summary>
 /// <param name="property">属性。</param>
 /// <param name="mode">模式。</param>
 public static IBindableProperty SetDataSourceUpdateMode(this IBindableProperty property, DataSourceUpdateMode mode)
 {
     property.DataSourceUpdateMode = mode;
     return(property);
 }
Beispiel #31
0
        public Binding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
        {
            DataSource        = dataSource;
            BindingMemberInfo = new BindingMemberInfo(dataMember);
            _bindToObject     = new BindToObject(this);

            PropertyName         = propertyName;
            _formattingEnabled   = formattingEnabled;
            _formatString        = formatString;
            _nullValue           = nullValue;
            _formatInfo          = formatInfo;
            DataSourceUpdateMode = dataSourceUpdateMode;

            CheckBinding();
        }
Beispiel #32
0
 public DisplayPropertyAttribute(object Default, string Property, string Name = null, DataSourceUpdateMode UpdateMode
                                 = DataSourceUpdateMode.OnPropertyChanged) : this(DisplayType.Unknown, Property, Default, Name, UpdateMode)
 {
 }
Beispiel #33
0
		public Binding (string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode)
			: this (propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, null, string.Empty, null)
		{
		}
 public static Binding Bind <TControl, TDataSourceItem>(this TControl control, Expression <Func <TControl, object> > controlProperty, object dataSource, Expression <Func <TDataSourceItem, object> > dataSourceProperty, bool formattingEnabled, DataSourceUpdateMode updateMode)
     where TControl : Control
 {
     return(control.DataBindings.Add(PropertyName.For(controlProperty), dataSource, PropertyName.For(dataSourceProperty), formattingEnabled, updateMode));
 }
 private static Binding BindInternal <TControl, TModel>(TControl control, LambdaExpression property, TModel model, LambdaExpression bind, bool formattingEnabled, DataSourceUpdateMode updateMode) where TControl : IBindableComponent
 {
     //validate
     CheckPropertyLambda(property, nameof(property));
     CheckPropertyLambda(bind, nameof(bind));
     return(control.DataBindings.Add(
                GetExpressionPath(property.Body as MemberExpression),
                model,
                GetExpressionPath(bind.Body as MemberExpression),
                formattingEnabled,
                updateMode
                ));
 }
Beispiel #36
0
 /// <summary>
 /// Sets the update mode for the source of the binding, i.e. when
 /// changes in the binding target are propagated to the source.
 /// </summary>
 /// <param name="value">The <see cref="DataSourceUpdateMode" /> to use for the source.</param>
 public CompleteBinding WithSourceUpdateMode(DataSourceUpdateMode value)
 {
     Binding.DataSourceUpdateMode = value;
     return this;
 }
 protected virtual void BindProperties(Control target, string targetProperty, string sourceProperty, DataSourceUpdateMode updateMode)
 {
     target.DataBindings.Add(targetProperty, Controller, sourceProperty, true, updateMode);
 }
Beispiel #38
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TControl"></typeparam>
 /// <typeparam name="TDataSource"></typeparam>
 /// <param name="property"></param>
 /// <param name="dataSource"></param>
 /// <param name="dataMember"></param>
 /// <param name="formattingEnabled"></param>
 /// <param name="dataSourceUpdateMode"></param>
 /// <param name="nullValue"></param>
 /// <param name="formatString"></param>
 /// <param name="formatInfo"></param>
 /// <returns></returns>
 private static Binding createBinding <TControl, TDataSource>(Expression <Func <TControl, object> > property, TDataSource dataSource, Expression <Func <TDataSource, object> > dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
 {
     return(new Binding(getName(property.Body), dataSource, getName(dataMember.Body), formattingEnabled, dataSourceUpdateMode, nullValue, formatString, formatInfo));
 }
Beispiel #39
0
        public void Binding_Ctor_String_Object_String_Bool_DataSourceUpdateMode(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode)
        {
            var binding = new Binding(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode);

            Assert.Null(binding.BindableComponent);
            Assert.Null(binding.BindingManagerBase);
            Assert.Equal(new BindingMemberInfo(dataMember), binding.BindingMemberInfo);
            Assert.Null(binding.Control);
            Assert.Equal(ControlUpdateMode.OnPropertyChanged, binding.ControlUpdateMode);
            Assert.Same(dataSource, binding.DataSource);
            Assert.Same(DBNull.Value, binding.DataSourceNullValue);
            Assert.Equal(dataSourceUpdateMode, binding.DataSourceUpdateMode);
            Assert.Null(binding.FormatInfo);
            Assert.Empty(binding.FormatString);
            Assert.Equal(formattingEnabled, binding.FormattingEnabled);
            Assert.False(binding.IsBinding);
            Assert.Null(binding.NullValue);
            Assert.Same(propertyName, binding.PropertyName);
        }
Beispiel #40
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TControl"></typeparam>
 /// <typeparam name="TDataSource"></typeparam>
 /// <param name="bindings"></param>
 /// <param name="property"></param>
 /// <param name="dataSource"></param>
 /// <param name="dataMember"></param>
 /// <param name="formattingEnabled"></param>
 /// <param name="dataSourceUpdateMode"></param>
 public static void Add <TControl, TDataSource>(this ControlBindingsCollection bindings, Expression <Func <TControl, object> > property, TDataSource dataSource, Expression <Func <TDataSource, object> > dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode)
 {
     bindings.Add(createBinding(property, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, null, string.Empty, null));
 }
 public static Binding Bind <TControl, TDataSourceItem>(this TControl control, Expression <Func <TControl, object> > controlProperty, object dataSource, Expression <Func <TDataSourceItem, object> > dataSourceProperty, bool formattingEnabled, DataSourceUpdateMode updateMode, object nullValue, string formatString, IFormatProvider formatInfo)
     where TControl : Control
 {
     return(control.DataBindings.Add(PropertyName.For(controlProperty), dataSource, PropertyName.For(dataSourceProperty), formattingEnabled, updateMode, nullValue, formatString, formatInfo));
 }
Beispiel #42
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TControl"></typeparam>
 /// <typeparam name="TDataSource"></typeparam>
 /// <param name="bindings"></param>
 /// <param name="property"></param>
 /// <param name="dataSource"></param>
 /// <param name="dataMember"></param>
 /// <param name="formattingEnabled"></param>
 /// <param name="dataSourceUpdateMode"></param>
 /// <param name="nullValue"></param>
 /// <param name="formatString"></param>
 /// <param name="formatInfo"></param>
 public static void Add <TControl, TDataSource>(this ControlBindingsCollection bindings, Expression <Func <TControl, object> > property, TDataSource dataSource, Expression <Func <TDataSource, object> > dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString, IFormatProvider formatInfo)
 {
     bindings.Add(createBinding(property, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString, formatInfo));
 }
		public Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode,
			object nullValue, string formatString)
		{
			return Add (propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, null);
		}
        public static ComboBox BindValue <TModel, TProperty>(this ComboBox control, TModel model, Expression <Func <TModel, TProperty> > value, DataSourceUpdateMode mode = DataSourceUpdateMode.OnPropertyChanged)
        {
            var propertyName = GetPlainPropertyName(control, value);

            control.DataBindings.Add("SelectedValue", model, propertyName, false, mode);
            return(control);
        }
        public void AddBinding(Control control, string propertyName, INotifyPropertyChanged dataSource, string dataMember, DataSourceUpdateMode dataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged)
        {
            Binding binding = new Binding(propertyName, dataSource, dataMember);

            binding.ControlUpdateMode    = ControlUpdateMode.OnPropertyChanged;
            binding.DataSourceUpdateMode = dataSourceUpdateMode;

            control.DataBindings.Add(binding);
            // 对同一个DataSource,仅需要注册一次事件Handler
            if (!m_RegisteredDataSource.Contains(dataSource))
            {
                dataSource.PropertyChanged += new PropertyChangedEventHandler(dataSource_PropertyChanged);
                m_RegisteredDataSource.Add(dataSource);
            }

            // build mapping from datasource + datamember -> control + propertyname
            string key = GetKey(dataSource, dataMember);

            List <DataBindingCtrlInfo> bindingCtrlInfos;
            DataBindingCtrlInfo        bindingCtrlInfo = new DataBindingCtrlInfo(control, propertyName, dataSource);

            if (m_DTDataSource2ControlProperty.ContainsKey(key))
            {
                bindingCtrlInfos = m_DTDataSource2ControlProperty[key];
                bindingCtrlInfos.Add(bindingCtrlInfo);
            }
            else
            {
                bindingCtrlInfos = new List <DataBindingCtrlInfo>();
                bindingCtrlInfos.Add(bindingCtrlInfo);
                m_DTDataSource2ControlProperty.Add(key, bindingCtrlInfos);
            }

            // MyLog4Net.Container.Instance.Log.DebugFormat("Add Binding key {0}, control: {1}, type {2}", key, control.GetHashCode(), control.Name);
        }
Beispiel #46
0
        /// <summary>
        ///  Erstellt eine Bindung, die die angegebene Steuerelementeigenschaft an den angegebenen Datenmember der angegebenen Datenquelle bindet, wodurch optional die Formatierung aktiviert wird, Werte basierend auf der angegebenen Aktualisierungseinstellung an die Datenquelle weitergegeben werden und der Auflistung die Bindung hinzugefügt wird.
        /// </summary>
        /// <typeparam name="TBindable">der Typ der Komponente, an die Daten gebunden werden sollen</typeparam>
        /// <typeparam name="TSource">der Typ des Objekts, das als Datenquelle dient</typeparam>
        /// <param name="bindable">die Komponente, an die Daten gebunden werden sollen</param>
        /// <param name="propertySelector">die Steuerelementeigenschaft für die Bindung</param>
        /// <param name="dataSource">ein System.Object, das die Datenquelle darstellt</param>
        /// <param name="dataMemberSelector">die Eigenschaft, an die die Bindung erfolgen soll</param>
        /// <param name="dataSourceUpdateMode"></param>
        /// <returns>das neu erstellte System.Windows.Forms.Binding</returns>
        public static Binding SetBinding <TBindable, TSource>(this TBindable bindable, Expression <Func <TBindable, object> > propertySelector, TSource dataSource, Expression <Func <TSource, object> > dataMemberSelector, DataSourceUpdateMode dataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged) where TBindable : IBindableComponent
        {
            string propertyName = propertySelector.GetMemberName();
            string memberName   = dataMemberSelector.GetMemberName();

            Binding oldBinding = bindable.DataBindings[propertyName];

            if (oldBinding != null)
            {
                bindable.DataBindings.Remove(oldBinding);
            }

            return(bindable.DataBindings.Add(propertyName, dataSource, memberName, true, dataSourceUpdateMode));
        }
Beispiel #47
0
 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] // 'formatString' is an appropriate name, since its a string passed to the Format method
 public Binding(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode dataSourceUpdateMode, object nullValue, string formatString) : this(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString, null)
 {
 }
Beispiel #48
0
 public static void ChangeBindingSourceUpdateMode(Type ctlType, Control containerCtl, DataSourceUpdateMode um)
 {
     foreach (Control ctl in containerCtl.Controls)
     {
         if (ctl.GetType() == ctlType)
         {
             ctl.DataBindings.DefaultDataSourceUpdateMode = um;
         }
         else if (ctl.Controls.Count > 0)
         {
             ChangeBindingSourceUpdateMode(ctlType, ctl, um);
         }
     }
 }
Beispiel #49
0
        public static void Add(ControlBindingsCollection dataBindings, string sP, object tO, string tP, bool formattingEnabled = true, DataSourceUpdateMode change = DataSourceUpdateMode.OnPropertyChanged)
        {
            Binding b = new Binding(sP, tO, tP, formattingEnabled, change);

            b.Format += Binding_Format;
            dataBindings.Add(b);
        }
	public Binding Add(string propertyName, object dataSource, string dataMember, bool formattingEnabled, DataSourceUpdateMode updateMode, object nullValue) {}