Binding datasource to a user control

Posted by Marc on 09-Dec-2013 04:41

Hi everyone,

I need to bind a Progress.Data.BindingSource to a property of my user control.

But the only property visible to the bindind wizard is the "Tag". Actually, this could be enough for me, but then, I have to display the new data stored in the Tag, and have no "Tag_Changed" event.

Any idea how to bind a custom property or to retrieve the Tag change ?

Marc.

All Replies

Posted by Lieven De Foor on 09-Dec-2013 10:11

Your best bet is to create the UserControl in pure .net and add the [Bindable] attribute to the property you want to bind.

ABL has no support to add compile time attributes (msdn.microsoft.com/.../ms171726.aspx) to (User)Controls (although there should be some way to do it using reflection)

Take a look at msdn.microsoft.com/.../ms171926.aspx and msdn.microsoft.com/.../ms233813.aspx

Posted by Mike Fechner on 10-Dec-2013 12:55

It is possible in ABL - but a lot of work.

First your property needs to become .NET visible. That can only be done by implementing a .NET interface requiring that property.

Then you need to add the Bindable attribute. That is possible by implementing the ICustomTypeDescriptor interface, but a lot of work (I've been there).

The pure .nET implementation as suggested by Lieven is probably easier! the free c# express edition is enough for that.

Posted by Marc on 20-Dec-2013 03:37

Hello,

Creating a pure .NET control works fine ! Thanks !

Here's the piece of code I wrote in C# to do this :

       [Bindable(true)]

       public string TextNET

       {

           get { return TextNETProperty; }

           set {   TextNETProperty = value;

                   textbox1.Text = value;

                   if (this.MyNewBindedValue != null) this.MyNewBindedValue(this, EventArgs.Empty);

           }

       }

Then the .NET dll needs to be stored in the root directory of my OE project, and the binding works! :)

This thread is closed