开发者

Cannot bind to the property or column [...] on the DataSource

开发者 https://www.devze.com 2023-01-15 14:07 出处:网络
I am trying to bind Font property of System.Windows.Forms.Label to a property of my class (via forms designer).

I am trying to bind Font property of System.Windows.Forms.Label to a property of my class (via forms designer).

This is the exception I am seeing "Cannot bind to the property or column HeaderText on the DataSource"

I tried making my class static and make it expose static properties - it didn't help.

The generated code looks like this:

    this.WindowTitle.Da开发者_开发问答taBindings.Add(new System.Windows.Forms.Binding("Font", this.fontManagerBindingSource, "HeaderText", true));
    // 
    // fontManagerBindingSource
    // 
    this.fontManagerBindingSource.DataSource = typeof(FontDefinitions.FontManager);

Here is the font manager class:

   public class FontManager
    {
        /// <summary>
        /// Gets or sets HeaderText.
        /// </summary>
        public static Font HeaderText
        {
            get { return new Font("Tahoma", 42); }

        }
    }

What am I doing wrong? Under what circumstances a property can not be bound?


Why do you want the property to be static? Its working if you make it non-static.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号