當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。