Binding Windows Form controls to a class as a data source

I want to bind each control on my Windows Form to a property in a a class.  Is this possible ?

In C#, I can select a TextBox, expand its DataBindings node in the Properties window, click the arrow next to the Text property, then click on the "Add Project Data Source" link.  This link does not appear in Visual COBOL.  Even if the link did appear, I'm not even sure if I can use my class.  On the "Choose data source type" window, you can select "Object" but this doesn't seem to be what I am looking for.

I know how to do this in WPF using the download from this link:

Can I do something like this with a Windows Form ?


  • We are using DevExpress for our user interface and they have a few things for me to try.  I'll let you know if that handles it.

  • Verified Answer

    Setting the binding through the GUI is not currently supported but you can set this up programmatically:

    Here is a simple example that binds the Text property of a textbox control to a string property.

         $set ilusing"System.Windows.Forms"
          class-id testwinform.Form1 is partial
                    inherits type System.Windows.Forms.Form.
          working-storage section.
          01 mystring   string  value "TEST" property.
          method-id NEW.
          procedure division.

              invoke self::InitializeComponent

          end method.

          method-id button1_Click final private.
          procedure division using by value sender as object e as type System.EventArgs.
              invoke textBox1::DataBindings::Add(new type Binding("Text", self, "mystring"))
          end method.
          end class.