TABCONTROL non parla con suo "padre" [RISOLTO]

Forum dedicato ai programmatori di X# in lingua italiana – Italian language forum

Moderator: wriedmann

User avatar
claudiocarletta
Posts: 101
Joined: Sat Sep 05, 2020 8:56 am

TABCONTROL non parla con suo "padre" [RISOLTO]

Post by claudiocarletta »

Salve a tutti,Forse sto facendo il passo più lungo della gamba ma ...In una DATADIALOG (vedi figura) ho messo due TABCONTROL e quindi ho scoperto che altro non sono che due DIALOGWINDOW figlie.
Immagine 2020-10-07 184155.jpg
Immagine 2020-10-07 184155.jpg (58.58 KiB) Viewed 383 times
Vorrei che: [*] [*]la connessione MySQL che ho istanziato nella DATADIALOG (padre) e che ho utilizzato per popolare la DATALISTVIEW degli alunni possa essere utilizzata anche dalle due TABCONTROL (figlie) per popolare in una i libri già prestati e nell'altra i libri che vorrei prestare [*]i value dei controlli (sottolineati in verde) possano essere visibili ai TABCONTROL ed eseguire quindi autonomamente le query necessarie In pratica che le finestre figlie possano leggere tutte le istanze e i controlli della finestra genitore.Ho provato ad esempio la query nella DIALOGWINDOW :[hr]cConnAs1 := "call biblioteca.LibAnnClas(?, ?, ?);"oSelectAs1 := SQLSelect{cConnAs1, oConnAs1}oSelectAs1:Execute(SELF:Owner:oDCCBAnSC:Value, SELF:Owner:oDCCBSezione:Value, SELF:Owner:oDCCBAnno:Value)[hr]ma in fase di esecuzione mi dice che (SELF:Owner:oDCCBAnSC:Value): XSharp.Error: 'No exported variable'Spero di essere stato chiaro.
Grazie a tutti,
buona serata
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

TABCONTROL non parla con suo "padre"

Post by ic2 »

Hello Claudio:

(Uso la traduzione automatica )

Forse ti fraintendo, ma oDCCBAnSC è un controllo su una finestra in stile VO? Se è così: in VO puoi impostare (nella seconda scheda delle proprietà della finestra) Export Controls su true. Invece di qualcosa come PROTECT oDCCBAnSC AS SingeLineEdit ottieni EXPORT ... (oppure puoi cambiarlo nella classe ma quando viene rigenerato tornerà a PROTECT). Non farlo è una buona causa per
l'errore Nessuna variabile esportata.
(Non uso moduli VO in X # quindi non sono sicuro che funzioni allo stesso modo)

English:

Maybe I misunderstand you, but is oDCCBAnSC a control on a VO style window? If so: in VO you can set (in the 2nd tab of the window properties) Export Controls to true. Instead of something like PROTECT oDCCBAnSC AS SingeLineEdit you get EXPORT ... (or you can change it in the class but when this is regenerated it will revert back to PROTECT). Not doing this is a good cause for the No exported variable error.
(I do not use VO forms in X# so I am not sure if it works the same)

Dick
User avatar
claudiocarletta
Posts: 101
Joined: Sat Sep 05, 2020 8:56 am

TABCONTROL non parla con suo "padre"

Post by claudiocarletta »

Grazie dei cosigli Dick,
ho provato a dichiarare tutti i controlli e le altre strutture EXPORT come mi hai consigliato

PARTIAL CLASS PresCons INHERIT DATADIALOG
EXPORT oDCCBAnSC AS COMBOBOX
EXPORT oDCCBCorso AS COMBOBOX
EXPORT oDCCBSezione AS COMBOBOX
EXPORT oDCCBAnno AS COMBOBOX
EXPORT oCCPBCercaAlunni AS PUSHBUTTON
EXPORT oDCDLAlunni AS DATALISTVIEW
EXPORT oDCFixedText1 AS FIXEDTEXT
EXPORT oDCFixedText2 AS FIXEDTEXT
EXPORT oDCFixedText3 AS FIXEDTEXT
EXPORT oDCFixedText4 AS FIXEDTEXT
EXPORT oDCCBMySQL AS CHECKBOX
EXPORT oCCPBChiudi AS PUSHBUTTON
EXPORT oDCGBnomi AS GROUPBOX
EXPORT oDCNewAlunno AS SINGLELINEEDIT
EXPORT oCCCercAlunno AS PUSHBUTTON

// {{%UC%}} User code starts here (DO NOT remove this line)

EXPORT oDCTab1 AS TABCONTROL
EXPORT oDCTab2 AS TABCONTROL
EXPORT oTab_1 AS DIALOGWINDOW
EXPORT oTab_2 AS DIALOGWINDOW
EXPORT oALunni AS DbServer
EXPORT oSfAlunni AS FileSpec
EXPORT oConnAs1 AS SQLConnection
EXPORT oSelectAs1 AS SQLSelect
EXPORT cConnAs1 AS STRING
EXPORT sDsn AS STRING
EXPORT sUser AS STRING
EXPORT sPass AS STRING

Ma nel momento in cui vado ad utlizzarle nel TABCONTROL mi dà lo stesso errore : XSharp.Error: 'No exported

Ho provato in vari modalità di accesso:
1) oSelectAs1:Execute(SELF:Owner:oDCCBAnSC:Value, SELF:Owner:oDCCBSezione:Value, SELF:Owner:oDCCBAnno:Value)
2) oSelectAs1:Execute(SELF:Owner:Owner:oDCCBAnSC:Value, SELF:Owner:Owner:oDCCBSezione:Value, SELF:Owner:Owner:oDCCBAnno:Value)

ottenento lo stesso errore.

Sicuramente sbaglio da qualche parte ma non riesco a capire dove

Grazie a tutti
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

TABCONTROL non parla con suo "padre"

Post by ic2 »

Hello Claudio,

Se aggiungi qualcosa di simile:

LOCAL c1,c2,c3 as string

c1:=SELF:Owner:oDCCBAnSC:Value
c2:=SELF:Owner:oDCCBSezione:Value
c3:=SELF:Owner:oDCCBAnno:Value

allora ottieni l'errore Nessuna variabile esportata su tutti e 3 i campi?

Se è così, potrebbe esserci qualcosa con il sé: Owner. Prova a vedere cosa ti dice il debugger quando digiti self: owner e poi self "owner: somevalues


=========================

If you add something like this:

LOCAL c1,c2,c3 as string

c1:=SELF:Owner:oDCCBAnSC:Value
c2:=SELF:Owner:oDCCBSezione:Value
c3:=SELF:Owner:oDCCBAnno:Value

then do yo get the No exported variable error on all 3 fields?

If so there may be something with self:Owner. Try to see what the debugger tells you when you type self:owner and then self"owner:somevalues


Dick
User avatar
claudiocarletta
Posts: 101
Joined: Sat Sep 05, 2020 8:56 am

TABCONTROL non parla con suo "padre"

Post by claudiocarletta »

Grazie sempre, ho provato a modificare il codice come mi hai suggerito ma non riesco a risolvere il problema.
Ti invio un po' di immagini relative al codice e al debug relativo nella speranza che tu o qualcun altro possa aiutarmi
Cattura.JPG
Cattura.JPG (14.38 KiB) Viewed 383 times
questo è il TABCONTROL nella DATADIALOG
Immagine 2020-10-08 234819.jpg
Immagine 2020-10-08 234819.jpg (20.64 KiB) Viewed 383 times
questo è il codice del controllo
Immagine 2020-10-08 234958.jpg
Immagine 2020-10-08 234958.jpg (59.84 KiB) Viewed 383 times
questo è il codice per istanziare il TABCONTROL con i due tab (sono stati fatti manualmente)
Immagine 2020-10-08 234055.jpg
Immagine 2020-10-08 234055.jpg (33.39 KiB) Viewed 383 times
Questo è l'errore che mi dà (con le modifiche che mi hai suggerito
Immagine 2020-10-08 234203.jpg
Immagine 2020-10-08 234203.jpg (24.13 KiB) Viewed 383 times
qui interrogo il SELF e sembra corretto
Immagine 2020-10-08 234241.jpg
Immagine 2020-10-08 234241.jpg (35.94 KiB) Viewed 383 times
qui interrogo il SELF:Owner che non mi dà errore ma mi aspettavo che mi desse la classe padre: PresCons
Immagine 2020-10-08 234419.jpg
Immagine 2020-10-08 234419.jpg (16.75 KiB) Viewed 383 times
qui interrogo una variabile sDsn che avevo definito nella classe padre come: EXPORT sDsn AS STRING

Se qualcuno avesse qualche consiglio da darmi oppure un esempio analogo su cui studiare ...
Grazie a tutti
Claudio
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

TABCONTROL non parla con suo "padre"

Post by ic2 »

self: il proprietario è sbagliato credo. __FormDialogwindow e credo sia una classe genitore VO Windows.

Non dovrebbe essere solo "SELF" poiché SELF è presCons2 e questa è la finestra su cui sembra che tu abbia i controlli?

PS: aggiungo sempre la classe a un metodo come in VO (method Postinit ... CLASS presCons2. Non è richiesto in X # (ma possibile) e questi frammenti di codice mostrano che senza CLASS non è chiaro al 100% da quale classe il metodo è senza vedere l'intero codice.

====================
self:Owner is wrong I think. It is __FormDialogwindow and that's a VO Windows parent class I believe.

Shouldn't it just be 'SELF" as SELF is presCons2 and that is the window you seem to have the controls on?

PS: I always add the class to a method like in VO (method Postinit ... CLASS presCons2 . It isn't required in X# (but possible) and these code snippets show that without the CLASS it's not 100% clear from which class the method is without seeing the whole code.

Dick
Jamal
Posts: 314
Joined: Mon Jul 03, 2017 7:02 pm

TABCONTROL non parla con suo "padre"

Post by Jamal »

Hi Claudio,

The best way to help you and us figure out the issue, is to create a small app to replicate the issue and post here.

Jamal
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

TABCONTROL non parla con suo "padre"

Post by Chris »

Hi Claudio,

Yes, please zip and post the solution, so we can have a look. What I suspect is happening, is that your code using Owner is in a method defined in the main window class (or in an other class), but not in the class of your tabpage, but can't be sure without seeing the complete code (of this module/prg at least).

About viewing SELF:Owner:sDsn in the debugger, unfortunately this is not possible right now. The problem is that SELF:Owner returns a USUAL and VS does not know how to handle usuals. Just showing the value of SELF:Owner is OK, but then showing the contents of Owner:sDsn requires a late bind call to the USUAL, in order to find and retrieve the sDsn var, but VS does not know about X#'s late binding. Maybe this is something that can be implemented in the future.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

TABCONTROL non parla con suo "padre"

Post by wriedmann »

Ciao Claudio,
prova a vedere l'esempio allegato.
Se usi il debugger vedi che la variabile oParent della finestra sul tabcontrol è la finestra principale:
DebugOutput.png
DebugOutput.png (2.43 KiB) Viewed 383 times
Perciò nel codice esempio questo funziona:

Code: Select all

method LeggiButton() class TabControl1_Page1
	oDCProva:Value			:= oParent:Prova
	return nil
TabScreen.png
TabScreen.png (4.78 KiB) Viewed 383 times
Saluti

Wolfgang
TabChildren.zip
(12.93 KiB) Downloaded 37 times
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
claudiocarletta
Posts: 101
Joined: Sat Sep 05, 2020 8:56 am

TABCONTROL non parla con suo "padre"

Post by claudiocarletta »

Grazie a tutti,
ho zippato una piccola applicazione del tutto simile a quella in sviluppo perché quella originale accedeva a MySQL e sarebbe stato troppo complicato provarla. L'errore che mi dà è uguale.
ProvaTab.zip
(1.66 MiB) Downloaded 36 times
Grazie a tutti
p.s. se preferite posto l'originale, non ho problemi
Claudio
Post Reply