tags:

views:

29

answers:

1

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.DataBindings.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?

A: 

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

Mamta Dalal
If I make in non-static, then the exception is not thrown, but the property is never read from my class. I thought that it was happening because the class was never instantiated.
Corvin