Destroying controls?
Publicado: Jue Jul 28, 2011 4:19 pm
I have a program that is making some edit & button controls in code, all
with a TGroupBox parent. This works fine.
oLabel := TLabel():New( ::oEditGroupBox )
oLabel:SetBounds( 50, 50, 100, 25 )
oLabel:cText := aRow[SE_EDITTEXT]
oLabel:Create()
oEdit := TMaskEdit():New( ::oEditGroupBox )
oEdit:SetBounds( 50, 100, 100, 25 )
oEdit:Create()
oSaveBtn := TButton():New( ::oEditGroupBox )
oSaveBtn:SetBounds( 50, 150, 100, 25 )
oSaveBtn:cText := "&Save"
oSaveBtn:Create()
oSaveBtn:OnClick := { |oSender| ::oIni:SetEntry( aRow[SE_SECTION],
aRow[SE_ENTRY], oEdit:value ) }
I want to clear/destroy these before I make a different combination of edit
& button controls.
So to destroy the controls on my TGroupBox I do something like this ....
Method ClearEditGroupBox() Class TForm1
local elem
FOR EACH elem IN ::oEditGroupBox:aControls
elem:destroy()
NEXT
::oEditGroupBox:Redraw()
RETURN Nil
This does not remove all controls, but leaves some visible which stay there
when I make some new controls in the TGroupBox.
So question is how to TOTALLY remove some TEdit & TButton controls made in
code, before I make some new ones in the TGroupbox..
I hope I have made this understandable!!
Chris
with a TGroupBox parent. This works fine.
oLabel := TLabel():New( ::oEditGroupBox )
oLabel:SetBounds( 50, 50, 100, 25 )
oLabel:cText := aRow[SE_EDITTEXT]
oLabel:Create()
oEdit := TMaskEdit():New( ::oEditGroupBox )
oEdit:SetBounds( 50, 100, 100, 25 )
oEdit:Create()
oSaveBtn := TButton():New( ::oEditGroupBox )
oSaveBtn:SetBounds( 50, 150, 100, 25 )
oSaveBtn:cText := "&Save"
oSaveBtn:Create()
oSaveBtn:OnClick := { |oSender| ::oIni:SetEntry( aRow[SE_SECTION],
aRow[SE_ENTRY], oEdit:value ) }
I want to clear/destroy these before I make a different combination of edit
& button controls.
So to destroy the controls on my TGroupBox I do something like this ....
Method ClearEditGroupBox() Class TForm1
local elem
FOR EACH elem IN ::oEditGroupBox:aControls
elem:destroy()
NEXT
::oEditGroupBox:Redraw()
RETURN Nil
This does not remove all controls, but leaves some visible which stay there
when I make some new controls in the TGroupBox.
So question is how to TOTALLY remove some TEdit & TButton controls made in
code, before I make some new ones in the TGroupbox..
I hope I have made this understandable!!
Chris