Moving the content of an array field of a bindingsource into

Posted by Kai Siegele on 02-Nov-2017 10:36

Hallo,

I have created a new ABL form-class with some textboxes on it.

Then I have added a Progress.Data.BindingSource-object to the form. This binding source is attached via query to a record of a table of a dataset.

I have added this binding source to the databindings of the textboxes to specify which field to show in the textbox f.e..

tbTCName:DataBindings:Add("Text",  bsTCJournal, "LastName").

Than I have filled the query and refreshed the binding.

When the content of the field is an array, the textbox remains empty.

Has anyone an idea how to get data from an array field of a bindingsource and move it into a textbox? Or what control is better suited to show the content of such an array?

Kind regards

Kai Siegele

All Replies

Posted by Laura Stern on 02-Nov-2017 12:17

Frankly, it makes no sense to show an array of values in a single text box.  What would you want to see?  The first array element?  It would be better to use a drop-down box or something like that where it would show all the values in a list.

Though having said that, I suspect that work either!   Usually a drop-down or regular list box gets values from a single field of mulitple records (like showing States from the state table), not elements from an array of a single record.

Posted by Kai Siegele on 03-Nov-2017 10:43

Hallo Laura,

thanks for your answer.

My favorite solution is to show the content of the array in textboxes and than to access via an index to the part of the array f.e.

tbTCCardStatusCode:DataBindings:Add("Array", bsTCJournal, "CardStatusCode(1)").

But I am afraid that it is not possible.

Unfortunately I cannot show the content of the array neither in a listbox nor in a combobox.

When trying f.e.

THIS-OBJECT:lbCardStatus:DataBindings:Add("Text", bsTCJournal, "CardStatusCode").

nothing happens

Have I made a mistake?

Kind regards

Kai Siegele

Posted by Laura Stern on 07-Nov-2017 08:02

Sorry - I  lost track of this thread.  I just don't think you can do this.  I seem to have left the important word out of my previous post.  It should have said " I suspect that WON'T work either!"  So no mistake: the BindingSource does not work with arrays.  Sorry again!

Posted by jquerijero on 07-Nov-2017 10:34

First thing to check: have you tried "<tablename>.LastName" instead of just "LastName"? I think you also need the table name and not just the column name.

Second, if the array type is not compatible with System.Array (ex. "System.String[]", "System.Int32[]" and etc.). You will need to initially bind the (array) column to the Tag property of the textbox then grab it later for conversion to some form of System.Array. If it is compatible, you can bind to Text like what you have.

Here are sample codes for binding array to textbox. You will eventually need an implementation of CurrencyManager or BindingNavigator to navigate through the array contents.

Ex. 1

DEFINE VARIABLE names AS "System.String[]" NO-UNDO.

names = NEW "System.String[]"(2).

names:SetValue("A", 0).

names:SetValue("B", 1).

THIS-OBJECT:ultraTextEditor1:DataBindings:Add("Text", names, ?).

Use THIS-OBJECT:ultraTextEditor1:DataBindings["Text"]:DataSource for the CurrencyManager or BindingNavigator.

Ex. 2

DEFINE VARIABLE bs AS System.Windows.Forms.BindingSource NO-UNDO.

bs = NEW System.Windows.Forms.BindingSource().

bs:DataSource = names.

THIS-OBJECT:ultraTextEditor2:DataBindings:Add("Text", bs, ?).

Posted by jquerijero on 07-Nov-2017 11:37

Try including the table name.

THIS-OBJECT:lbCardStatus:DataBindings:Add("Text", bsTCJournal, "TABLENAME.CardStatusCode").

This thread is closed