[Gambas-user] Access controls outside a form

Muriel Bodard abidoo.too at ...11...
Tue Jan 3 11:48:48 CET 2006


Le Lundi 02 Janvier 2006 23:15, Oliver Etchebarne Bejarano a écrit :
> Hello,
>
> I was googling a little, but I didn't find any solution to this :( My
> starting class is not a form (I have a Sub Main() ), but I want to fill
> data on a listbox inside a form. In VB (*ugh*) you could do:
>
> form.listboxcontrol.additem ("foobar")
>
> but I can't do that in Gambas :( Any idea?

if you want to work like in vb you must check public form in project options.

But you need to know that is not a good way of programming..;

2 other ways are possibles :

Pass an object reference to your procedure


FillList(lst as listbox)

	lst.add("foobar")

end


or a public function accessible on your form :

'Gambas form

Public sub ListAdd(sItem as string)
	ListBox1.Add(sItem)
end


in main :

MyForm.ListAdd("FooBar")


A big project like gambas ide don't work with public form, it take a wheel to 
forget that bad use but at term it's better and you can do more powerfull and 
more easy to maintain things.

Regards,
Fabien Bodard




>
> Thanks,





More information about the User mailing list