DataSource and DataField

Hi everyone,

i found a very good use for DataSource. I simply add in some string eg “SaleDetails” in the Sale Details tab for all the field i want to initialize (eg setting text to “” and checkbox to false) and i use the following codes to set all those fields

DIM i AS integer,j AS integer DIM vctrl AS Control j=self.controlcount - 1 for i = 0 to j vctrl=self.Control(i) if vCtrl isa TextField then IF TextField(vCtrl).DataSource="SaleDetails" THEN TextField(vCtrl).Text="" END IF elseif vCtrl isa TextArea then IF TextArea(vCtrl).DataSource="SaleDetails" THEN TextArea(vCtrl).Text="" END IF elseif vCtrl IsA CheckBox then IF CheckBox(vCtrl).DataSource="SaleDetails" THEN CheckBox(vCtrl).Value=False END IF elseif vCtrl IsA Combobox then IF Combobox(vCtrl).DataSource="SaleDetails" THEN Combobox(vCtrl).Text="" Combobox(vCtrl).ListIndex=-1 END END IF Next

Interesting. After all these years the Datasource and Datafield are still properties on the datafield yet no information in the xojo documentation on how to use these.

Any update would be apprecieated.

Short answer: ignore them. They expose very rudimentary functionality. You get much better functionality and flexibility by doing the same thing in code.

The DataSource and DataField properties were deprecated in 2018r4. As Tim says, they are very limited and it’s better to do things in code.