[Gambas-user] How to copy a frame containing various controls

Tobias Boege taboege at ...626...
Sat Dec 21 11:12:40 CET 2013


On Fri, 20 Dec 2013, ub2 at ...36... wrote:
> Dear Cracks,
> 
> 
> I want to show various CsvLines in a ScrollView.
> Each line will be splitted and filled in a bunch of controls which are
> all neatly placed and formatted in a "SourceFrame".
> 
> My question:
> Is there an easy way to copy/paste that "SourceFrame" depending on the
> (flexible) amount of CsvLines ?
> 
> 
> Or in other 'words':
>  FrameDat0: TextBoxTxt0, CheckBoxLock0, .., BtnSaveFrameDat0
> and
>  N=AmountCsvLines
> 
> shall become
>  FrameDat0: TextBoxTxt0, CheckBoxLock0, .., BtnSaveFrameDat0
>  FrameDat1: TextBoxTxt1, CheckBoxLock1, .., BtnSaveFrameDat1
>  FrameDat2: TextBoxTxt2, CheckBoxLock2, .., BtnSaveFrameDat2
>  ..
>  FrameDatN: TextBoxTxtN, CheckBoxLockN, .., BtnSaveFrameDatN
> 
> 
> I can do that in the IDE by copy/paste, but how to do it by code?
> Using a gridview does not allow all the formatting I need.
> 
> 
> Any good ideas or 'magic strategies' ?
> (I got stuck. Code explodes and becomes unflexible)
> 

Well, you can copy your SourceFrame and stuff but I won't elaborate on this
way until you explicitly rejected the sane OOP way :-)

Which goes like this:

 - create a form "CsvLine",
 - arrange your TextBoxes, CheckBoxes, ..., Buttons on it,
 - write a _new() method which takes a CSV line and parses it into the
   controls,
 - create an array of these Forms into a container on your main form (one
   for each CSV line).

This is a quite advanced topic; hope you can deal with the strategy above...

IIRC, you're german. You can have a look at an article where we created
custom controls using Forms[0], or my project[1] where this is done more
excessively.

Regards,
Tobi

[0] http://www.gambas-buch.de/dw/doku.php?id=k18:k18.12:start
[1] http://www.gambas-buch.de/dw/doku.php?id=k27:k27.4:start




More information about the User mailing list