Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
FORM WINDOW - exchange between 2 forms

ECHANGER DES DONNEES ENTRE 2 FORM


Bonjour,
Aujourdhui nous allons apprendre comment echanger des donnees d'un form à l'autre.
En effet, il est bien pratique de construire un programme multifenêtre.
Pour ceux qui ont l'habiude de VB, il fallait simplement nommer le form puis passer l'argument en parametre ( exemple : Form2.textbox.text = "babaorum" )
Sous Gambas linux ,c'est un peu plus difficile mais cela a l'avantage de séparer le code des Forms grace aux modules.
Trève de bavardage ,passons aux travaux pratiques :

Tout d'abord créons un projet, nommé exchangedata puis dans le fomr Fmain, mettons une textbox1 puis un Button1, ce qui nous donne ceci :

form1.jpg

creons une deuxieme fenetre avec la meme chose, Form1,button1 et textbox1 et voila :

form2.jpg

Ah oui j'oubliais un textlabel aussi, vous l'aurez deviné.!

maintenant creons un module nommé moduletransfert
definissons une variable avec la commande :
public texte as string

maintenantpassons au code de Fmain.
Double cliquez sur le button1 de fmain et ecrivez ce code dans Button_click
codeform1.jpg

dans le Form1 ecrivez ce code :

PUBLIC SUB form_OPEN()
textbox1.text = moduletransfert.texte

Exécutons notre application et voila ce que cela donne :

final.jpg


Pour résumer voici une petite info au format PDF ICI.

voici les sources de l'exemple ICI à télécharger .



essaimicio.jpg
Une petite information cependant.
Après réflexion, il est tout à fait possible d'echanger des donnees entres deux form sans passer par un module.

Il suffit de mettre dans le premier FORM

PUBLIC SUB button1_click()
form1.ajoutexte(textbox1.text)
END

et dans l'autre form ecrire


PUBLIC SUB form1_ajoutexte(montexte AS String)
textbox1.text = montexte
END

CI joint les sources de l'exemple ICI
Merci à Micio pour sa remarquewink




Creation date : 30/03/2009 @ 14:24
Last update : 12/02/2012 @ 10:45
Category : FORM WINDOW
Page read 6542 times


Print the article Print the article


react.gifReactions to this article


Reaction #5 

by polo 04/07/2011 @ 08:16

lack of funding that has been allocated to force, fraud, or coercion can be very difficult considering that the victims have often times been brain washed, beaten, raped, raped, polo femme raped, molested, threatened, and tormented and fear revealing the identity of their trafficker," he continued.During an April 18 appearance with Demi Moore on CNN's "Piers Morgan Tonight," Kutcher quoted a figure that has been widely used in publications, including The The Casque Monster beats by Dr. DreThe New York Times and USA Today."It's between 100,000 and 300,000 child sex slaves in the United States today," Kutcher Morgan, referring to the number of American children forced into prostitution every year. "If you don't do something

Reaction #4 

by spheris 24/12/2010 @ 17:09

pour récuperer le focus, utilise cette fonction :
TextBox1.SetFocus()
à chaque appuie d'une touche
wink

Reaction #3 

by caracole 24/12/2010 @ 14:50

oui, mais comment faire en sorte que chaque caractere frappé dans la FMain soit transmis dans
la zoner de texte de Form1 ?
'ceci fonctionne, mais on perd le focus de Fmain
'comment redonner le focus ?
PUBLIC SUB TextBox1_Change()
moduletransfert.texte = TextBox1.Text
Form1.show
END


Reaction #2 

by micio 15/05/2009 @ 22:15

ça y est ! c'est bon

Reaction #1 

by micio 15/05/2009 @ 18:22

J'ai pas l'impression que la 2me solution fonctionne


QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^