当前位置: 首页>>代码示例>>C#>>正文


C# Binding.WriteValue方法代码示例

本文整理汇总了C#中System.Windows.Forms.Binding.WriteValue方法的典型用法代码示例。如果您正苦于以下问题:C# Binding.WriteValue方法的具体用法?C# Binding.WriteValue怎么用?C# Binding.WriteValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Binding的用法示例。


在下文中一共展示了Binding.WriteValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindSelectedIndexChanged

        // We need to force WriteValue() on SelectedIndexChanged otherwise it will only call WriteValue()
        // on loss of focus.
        // http://stackoverflow.com/questions/1060080/databound-winforms-control-does-not-recognize-change-until-losing-focus
        /// <summary>
        /// Binds the specified combobox
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static Binding BindSelectedIndexChanged(ComboBox cmb, Binding b)
        {
            cmb.DataBindings.Add(b);
            cmb.SelectedIndexChanged += (sender, e) => { b.WriteValue(); };

            return b;
        }
开发者ID:kanbang,项目名称:Colt,代码行数:16,代码来源:ComboBoxBinder.cs

示例2: BindValueChanged

        // We need to force WriteValue() on CheckedChanged otherwise it will only call WriteValue()
        // on loss of focus.
        // http://stackoverflow.com/questions/1060080/databound-winforms-control-does-not-recognize-change-until-losing-focus
        /// <summary>
        /// Binds the specified NumericUpDown control
        /// </summary>
        /// <param name="num"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static Binding BindValueChanged(NumericUpDown num, Binding b)
        {
            num.DataBindings.Add(b);
            num.ValueChanged += (sender, e) => { b.WriteValue(); };

            return b;
        }
开发者ID:kanbang,项目名称:Colt,代码行数:16,代码来源:NumericBinder.cs

示例3: BindText

        // We need to force WriteValue() on TextChanged otherwise it will only call WriteValue()
        // on loss of focus.
        // http://stackoverflow.com/questions/1060080/databound-winforms-control-does-not-recognize-change-until-losing-focus
        /// <summary>
        /// Binds the specified text box
        /// </summary>
        /// <param name="txt"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static Binding BindText(TextBoxBase txt, Binding b)
        {
            txt.DataBindings.Add(b);
            txt.TextChanged += (sender, e) =>
            {
                b.WriteValue();
            };

            return b;
        }
开发者ID:kanbang,项目名称:Colt,代码行数:19,代码来源:TextBoxBinder.cs

示例4: DataSourceNullValueTest

		public void DataSourceNullValueTest ()
		{
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			ChildMockItem item = new ChildMockItem ();
			item.ObjectValue = "A";
			Binding binding = new Binding ("Tag", item, "ObjectValue");
			binding.DataSourceNullValue = "NonNull";

			c.DataBindings.Add (binding);
			Assert.AreEqual (c.Tag, "A", "#A1");

			// Since Tag property doesn't have a 
			// TagChanged event, we need to force an update
			c.Tag = null;
			binding.WriteValue ();
			Assert.AreEqual (item.ObjectValue, "NonNull", "#B1");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:20,代码来源:BindingTest.cs

示例5: WriteValueTest

		public void WriteValueTest ()
		{
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			MockItem item = new MockItem ();
			item.Text = "A";
			Binding binding = new Binding ("Text", item, "Text");
			binding.DataSourceUpdateMode = DataSourceUpdateMode.Never;

			c.DataBindings.Add (binding);
			Assert.AreEqual ("A", c.Text, "#A1");

			c.Text = "B";
			Assert.AreEqual ("A", item.Text, "#B1");

			binding.WriteValue ();
			Assert.AreEqual ("B", item.Text, "#C1");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:20,代码来源:BindingTest.cs


注:本文中的System.Windows.Forms.Binding.WriteValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。