[Gambas-user] How to mention (in code) widgets which are in sub form , in the main fourm's code ?
zxMarce
d4t4full at ...626...
Tue Feb 16 18:18:28 CET 2016
You can also -instead of using variables- publish the required
methods/properties from a form, so other parts of the program can do
whatever you need in a more encapsulated way.
Assume Form1 needs to add text to a control on Form2. I would go as follows:
FORM2 CODE:
* Public Sub AddText(newText As String)
Listbox1.Add(newText)
Me.Show 'This is optional.
End*
FORM1 CODE:
* Private $myF2 As New Form2
[ ... more code ...]
$myF2.AddText("Add This Text!")*
You can either have Form2 as a private object to Form1 as shown or it can be
set up in a global module as a global reference. Your choice.
Advantages are several: You can customize whatever you do with the text (in
the example) in one place only, or you can change the control
(*Form2.Listbox1* in this case) to a different type (*ListView* maybe?) and
not have to edit your whole program to adapt to the change.
HTH,
zxMarce.
--
View this message in context: http://gambas.8142.n7.nabble.com/How-to-mention-in-code-widgets-which-are-in-sub-form-in-the-main-fourm-s-code-tp55455p55461.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list