[Gambas-user] How do I delete a control on scrollview the correct way?

Ron Onstenk ronstk at ...239...
Tue Jun 6 08:53:23 CEST 2006


 
on the forma  Scrollview1 as SVFrames

public function wsadd() 
  fra = NEW Frame(SVFrames) AS "WSfra" 
  lbl = NEW Label(fra) 
  btn = NEW button(fra)
  tgb = NEW ToggleButton(fra)
  lv = NEW ListView(fra) AS "WStbl"
end


public wsdel(fra as frame)
  PRINT "fra.id="; fra.Id
PRINT "children.count="; fra.Children.Count ' =4
  FOR EACH ct IN fra.Children 'remove controls from frame
    ct.Delete  '<--- does not work
  NEXT  
  fra.Delete  '<--- does not work
PRINT "children.count="; fra.Children.Count 'is still 4

  fra.Enabled = FALSE
  showfra	
end


for both prints I get 4 children. More stupid is the second print. 
If the frame.delete is done it can't have children anymore.

In the scrollview the count of frames add with wsadd
stay the same after delete.
It only grows with wsadd but never lower with wsdel.

in showfra is the next WsTableGetFra used
after wsdel has run the frame is not visible anymore
but it is also not realy go to nothing


PUBLIC FUNCTION WsTableGetFra() AS Object[]
  DIM ctl AS Control
  DIM fra AS Frame
  DIM objs AS NEW Object[]

  FOR EACH ctl IN SVFrames.Children
    IF object.Type(ctl) = "Frame" THEN 
      fra = ctl
PRINT "fra "; fra.tag <----- not changed after delete

      IF object.IsValid(fra) THEN  '<--- stay valid after fra.delete
PRINT "isValid "; fra.tag 'always
      
        IF NOT IsNull(fra) THEN '<--- should be null but isn't
PRINT "NOT IsNull "; fra.tag    '<------never 
PRINT "children.count="; fra.Children.Count '<--- stay at 4
          IF fra.Enabled THEN objs.Add(fra)
        ENDIF  
      ENDIF  
    ENDIF  
  NEXT 

end

I have only a workaround with the frame.enabled but this
should be imposible.

Someone a tip what is wrong?

Ron




More information about the User mailing list