Autore Topic: Controllo Datasource  (Letto 366 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.298
  • Ne mors quidem nos iunget
    • Mostra profilo
Controllo Datasource
« il: 25 Marzo 2014, 02:20:50 »
Vi riporto questa discussione apparsa nella m.l. ufficiale:

" Hi

I have used Gambas very successfully in conjunction with a Sqlite database, but I have written my own procedures to exchange data between the  controls and the database. This provides great flexibility but does require quite a lot of code.

I am now experimenting with the use of the data-bound controls. I need to perform some validation before a record is saved, and require the option to abort the save entirely. The documentation describes a "BeforeSave" event for the datasource control which is just what I need. However, I can find no way of trapping this event as the IDE does not appear to provide the option of generating the event handler. I have tried inserting the appropriate code manually but it has no effect.

Grateful for any advice.

Thanks

Nige
"


" At the moment the BeforeSave() event handler cannot stop the save
process. I can add that in the next version (i.e. if you call STOP EVENT
during BeforeSave(), no save is performed) but not for the current version.

What sort of validation do you need? Maybe there is a workaround: for
example, the DataControl has a "Validate" event that allows to
individually validate the data entered by the user.

--
Benoît Minisini
"


" Hi Benoit

I have tested the .validate() event of the datacontrol. It meets my requirement to test and modify the data entered in the control but is there any way to abandon the save entirely if certain criteria are not met?

Thanks

Nige
"


" Yep: if you call STOP EVENT from the Validate event handler, you will abort the save.

--
Benoît Minisini
"
« Ultima modifica: 30 Marzo 2014, 16:07:47 da vuott »
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »