Trying to get my head around ProBindingSources

Posted by ojfoggin on 27-Jul-2009 04:51

I may well consider asking for some formal Progress training soon.

I'm beginning to realise how much you can do with .NET but also how much even the basics have changed compared to the old ABL GUI.

Again I am struggling at step 1 with trying to get this to work.  Any help would be greatly appreciated.

The documentation doesn't seem to show what I can see when I try to follow it.

I have a temp table (tt-customer) which is populated by an AppServer request.

I then have a DataGridView and I want to display the name and number of each customer in tt-customer in the DataGridView.

This appears to be deceptively simple in the Design View of Architect.

I add a ProBindingSource and tell it the table name (tt-customer) and field names (name (char), number (int)).  I add a DataGridView and attach the ProBindingSource to it and tell it which columns I want to display.

This saves and compiles with no problems but when I try to run it it tells me... "Incompatible datatypes found during runtime conversion."  This happens even if all I have done is add the ProBindingSource and nothing else.

The documentation about .NET stuff does not show any of the Visual Deigner stuff though and seems to only show how to code it manually but I can't work out how to integrate the code in to the automatically created code from Visual Deisgner.

Please can someone let me know what steps I should be taking to display a temp table in a DataGridView please.

Thanks

All Replies

Posted by Admin on 27-Jul-2009 04:57

Out of my head:

DEFINE QUERY qQuery FOR tt-customer SCROLLING.

OPEN QUERY qQuery FOR EACH tt-customer .

bindingSource1:Handle = QUERY qQuery:Handle.

The Handle property of the bindingSource accepts a ProDataset (navigating the top-nav-query), a query or a buffer. In case of the buffer, the binding sources count will return 1 and you'd have only a single row in the Grid.

I may well consider asking for some formal Progress training soon.

In Germany we are cooperating with Progress and provide the GUI for .NET class as a 3 day training. It's not re-learning the fundamentals of the 4GL, but a lot of new stuff. Get's even more interesting when you start to update data :-)

Posted by ojfoggin on 27-Jul-2009 05:20

Thanks for the reply.

I am still having trouble with this.

What I have done is this...

Add the ProBindingSource in the Visual Designer.
Add the table (tt-customer) and fields (name, number) to the ProBindingSource Designer.

Defined the query.

Opened the query (after the intialize components auto code).

Assigned the bindigSource1:HANDLE = QUERY lq-query:HANLDE.

Added a DataGridView.

Attached bindingSource1 to the grid view and edited the columns.

This saves and compiles but when I run it the line...

CAST(THIS-OBJECT:bindingSource1, System.ComponentModel.ISupportInitialize):BeginInit().

causes the incompatible datatypes error.

This is auto generated code though and if I try to change it the Visual Designer shouts at me and doesn't display the window.

The code in the .NET manual only shows how to do this in a .p file and so makes the Visual Designer void as it does not use this.

Is there a .NET manual that relates to Architect and the Visual Designer i.e. .cls creation?

Thanks again

Posted by rbf on 27-Jul-2009 06:15

Oliver,

It is important to realize that the design time stuff is merely that - design time stuff to give you some sort of preview at design time.

At run time your code is executed instead.

Could it be true that the data types you defined at design time are different from the data types at run time?

Posted by ojfoggin on 27-Jul-2009 06:21

The first thing I thought was that the data types I had chosen were different from the actual data types but I have checked these and they were all ok.

In order to get the incompatible data types error all I need to do is add the ProBindingSource, compile it and run it.  I don't need to change anything to get this error.

This will give the incompatible datatypes error at runtime.

If I then delete the probindingsource and compile it it will run with no errors.

Having had a loko at some other manuals it appears that the UltrGrid is designed to work with the ProBindingSource.  Does this mean that the normal DataGridView class will not work with it?

Posted by Admin on 27-Jul-2009 06:46

Can you share a .cls file that fails with us?

Posted by ojfoggin on 27-Jul-2009 08:01

Well... in response to your question I tried creating a new .cls file to do the same thing but it didn't go wrong.

I then recreated my file from scratch and it now appears to be working?!

I now only need to output the contents of the temp-table to the DataGridView

Posted by kevin_saunders on 27-Jul-2009 08:17

I have seen this happen too.. Well, not the same error, but when deleting a control, not all of the generated code gets removed..

Posted by ojfoggin on 27-Jul-2009 08:24

Well, I got it working and now on the final compile before I was about to test it all I get an error on the final END CLASS.

"Name already defined as a public property in inherited class."

Posted by ojfoggin on 27-Jul-2009 08:45

Nevermind,

I've given up now.

Given that it has taken me a day and a half to try getting this running and in the same amount of time in AppBuilder I could have finished it, I see no point in continuing much further.

If the thing compiles and runs then the DataGridView is empty.

Sometimes it won't compile.

Other times it runs and gives incompatible data types error (just ended on that now).

All I want is to diaplay a temp-table.  I can do that in less than 5 mins the "old" way.

I have tried to interpret every manual I can find on binding data to controls and none of them seem to have a simple method to follow that will do something (like a hello world).

I will try to recreate a program that gives the incompatible data types error.

Posted by Shelley Chase on 27-Jul-2009 12:57

Hi Oliver,

I agree with you that has more steps than AppBuilder and we are working on simplifying that for 10.2B. But in the meantime I have attached a working sample of a datagridview displaying customer records (as long as I copied all the files - let me know if you have any trouble).

If you can help me understand what was missing from the documentation we can work on clarifying it (the code in the .p should be the same code in the class. As you are well aware data binding is at the heart of ABL applications so this is a very important area for us to make clear. If you want to send me a small sample that does not work - please feel free. I do not know whether you tried using the Visual Designer or not.

I also noticed that some code was generated but not deleted when I changed the grid column definitions. I will log a bug.

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/0825.assemblies.xml:550:0]

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/customerFill.i:550:0]

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/customerTT.i:550:0]

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/5621.Form1.cls:550:0]

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/6320.Form1.resx:550:0]

-Shelley

Posted by ojfoggin on 27-Jul-2009 14:19

Hi Shelley,

Thanks for the examples!  I'm at home now so don't have access to Progress but I've had a read through the .cls and the .i files and already I can see how it will work.

So far the documentation has been good with regards publishing messages, running code using OO design, accessing data from an AppServer, etc...

The problem I was having with the data binding is that there is no real basic/generic explanations.

Even something as simple as ...

[pseudo code]

create temp table called tt-test

create databoundcontrol (i.e. datagridview, etc...)

create probindingsource

attach all three together

[/pseudo code]

Before GUI for .NET I had never heard of a prodataset and I couldn't find the basics of how to attach a temp table to one.

I think the reason I was so frustrated is that I could see that data binding was the one thing I needed to get past in order to access the full functionality of the GUI for .NET.

Now that I can turn a temp table (as temp tables are probably the only data source we use client side) into a dataset I can now take the documentation that explains how to attach a dataset to a databoundcontrol and put it to good use

Thanks for the help.

I'll let you know how it goes tomorrow!

Oliver

Posted by Admin on 27-Jul-2009 14:26

Before GUI for .NET I had never heard of a prodataset and I couldn't find the basics of how to attach a temp table to one.

I see a common pattern - heard that many times before. People take the GUI for .NET as a reason to look into many new language features like the ProDataset. Using them all in the end is the ultimate goal - not the requirement to start with.

Believe me you don't have to use ProDatasets when you start with GUI for .NET, and you don't have to use DataBinding as well. Start slowly and in steps at your own pace. It's nice when ProDatasets, N-Tier, OERA, OO and GUI for .NET play together. But it can be a lot of new stuff (depending on where one starts).

Did I already mention getting the Infragistics Grid playing as you want ? ;-)                 

Posted by ojfoggin on 27-Jul-2009 14:40

mikefe wrote:

People take the GUI for .NET as a reason to look into many new language features like the ProDataset. Using them all in the end is the ultimate goal - not the requirement to start with.            

I think the reason I went down the ProDataSet path is that the GUI for .NET seems to go hand in hand with Architect, which then comes with Visual Designer and the first thing you see when you expand the Progress Controls sub menu is ProBindingSource which then takes you to the documentation and introduces you to ProDataSets.

As a newbie it seemed the obvious path to follow.

Posted by ojfoggin on 28-Jul-2009 05:31

WOOO HOOO!!!

I was having a bit of trouble to begin with as our software isn't connected to the database so I had to use my temp table like you are using Customer and then create a temp-table from it.  I'm sure this is not the best way but it works for now

Yay!  Thanks!

One more quick question.  Is there any way to remove the arrow column down the left hand side of the datagridview?

Thanks again!

(Found it now, RowHeadersVisible)

Could someone please explain what code is not being deleted properly.

I have received the "Incompatible data types during run-time conversion" error again and woudl like to get round it.

Posted by Matt Baker on 28-Jul-2009 09:03

Hi Oliver,

I played with this a bit after Shelley mentioned it.  If the steps you are doing are the same as I have tested, then the "incompatible datatypes" error you are getting is because of the names you are using for the columns of the grid view.  The MS Data Grid View uses the names of the columns that you add as the names of the variables.  If you create a column named "Name" then it generates a variable into the code as "define private variable Name as System.Windows.Forms.DataGridViewTextBoxColumn no-undo".  This conflicts with the "Name" property of the actual form.  The ABL compiler does not allow variable/property shadowing so you get this error message when the "Name" variable/property is assigned.  To fix it, just change the name of the column to something that does not conflict with one of the form/control properties.

You probably wouldn't run into this with someone elses control such as the Infragistics controls since they don't generate class member variables for the columns.

Posted by ojfoggin on 28-Jul-2009 15:46

Thanks Matthew,

I'll have a look at that tomorrow.  I think I'm stuck at the moment as if I delete the extra bindingSources and DataGrids (apart from the first one that still works) then everything is fine.  As soon as I then add a bindingSource (even without defining columns) I get the error again.

(Could this be a result of the code deletion bug?)

Anywho, I'll have a looksy tomorrow.  I've managed to do more today with GUI for .NET than ever previously.

Thanks for the help!

This thread is closed