Page 1 of 1

Parents and children

Posted: Tue Jul 07, 2009 3:36 am
by albert
Why can`t an array element be a parent??

I keep getting errors that say mypanel(0) is not an object.

Parents and children

Posted: Tue Jul 07, 2009 8:28 am
by fred
I`m not sure what you mean but you can define a array of objects but not an array of properties if i`m right.
You want to use mypane(0).Color (or something like that)?

Parents and children

Posted: Tue Jul 07, 2009 4:53 pm
by albert
dim myform as form

dim tab as tabcontrol
tab.parent=myform
tab.Tabs(0)="01"
tab.Tabs(1)="02"
tab.Tabs(2)="03"
tab.Tabs(3)="04"


dim panels(4) as panel
panels(0).parent=tab
panels(1).parent=tab
panels(2).parent=tab
panels(3).parent=tab


dim edits(4) as edit
edits(0).parent=panels(0)  ```` error says panels(0) not declared !!!
edits(1).parent=panels(1)
edits(2).parent=panels(2)
edits(3).parent=panels(3)



myform.ShowModal

Parents and children

Posted: Wed Jul 08, 2009 10:57 am
by fred
It looks like the compiler does not know the array on the right side.
For this the admin or others will have to answer this one :(

Parents and children

Posted: Tue Jul 14, 2009 8:59 am
by PaPi
Hi guys, here is an example for albert`s problem:
(not with "edit", rather with "richedit")

`tab_example by PaPi
dim myform as form
dim i as integer
dim tab as tabcontrol
tab.parent=myform
tab.Tabs(0)="00"
tab.Tabs(1)="01"
tab.Tabs(2)="02"
tab.Tabs(3)="03"
tab.onchange=TC

dim panels(4) as panel
for i=tab.TabsCount to 0 step -1
     panels(i).parent=tab
     panels(i).left=6
     panels(i).top=26
     panels(i).caption="this is panel "+str$(i)
     panels(i).width=tab.width-12
     panels(i).height=tab.height-32
next i

dim richedits(4) as richedit
for i=tab.TabsCount to 0 step -1
     richedits(i).parent=tab
     richedits(i).left=6
     richedits(i).top=26
     richedits(i).text="this is richedit "+str$(i)
     richedits(i).width=tab.width-12
     richedits(i).height=(tab.height-32)/tab.TabsCount*(i+1)
next i

tab.tabindex=0
TC()

myform.ShowModal  


sub TC()
     dim i as integer
     for i=0 to tab.TabsCount
     if i=tab.tabindex then
           panels(i).visible=true
           richedits(i).visible=true
     else
           panels(i).visible=false
           richedits(i).visible=false
     end if
     next i
end sub

best regards
PaPi