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
In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Destroying controls?
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
- ignacio
- Site Admin
- Mensajes: 9447
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Destroying controls?
Chris Gillard escribió el jue, 28 julio 2011 16:19So question is how to TOTALLY remove some TEdit & TButton controls
Chris,
Try this (have not tested):
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:RemoveControl( :aControls[ 1 ] )
end do
end with
Regards,
Chris,
Try this (have not tested):
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:RemoveControl( :aControls[ 1 ] )
end do
end with
Regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Destroying controls?
Ignacio,
Thanks for that code.
The loop is reducing the len to aControls to ZERO as it should ... good.
But the Groupbox still has the 'image' of the controls visible.
I have tried GroupBox:Redraw() & GroupBox:Refresh()
Still the 'image' stays.
When new controls are created, I see the new ones and the old ones.
Any thoughts
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e3176c0$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris Gillard escribió el jue, 28 julio 2011 16:19
>> So question is how to TOTALLY remove some TEdit &
>> TButton controls
>
>
> Chris,
> Try this (have not tested):
> with object ::oEditGroupBox
> do while Len( :aControls ) > 0
> :RemoveControl( :aControls[ 1 ] )
> end do
> end with
>
>
> Regards,
> --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
Thanks for that code.
The loop is reducing the len to aControls to ZERO as it should ... good.
But the Groupbox still has the 'image' of the controls visible.
I have tried GroupBox:Redraw() & GroupBox:Refresh()
Still the 'image' stays.
When new controls are created, I see the new ones and the old ones.
Any thoughts
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e3176c0$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris Gillard escribió el jue, 28 julio 2011 16:19
>> So question is how to TOTALLY remove some TEdit &
>> TButton controls
>
>
> Chris,
> Try this (have not tested):
> with object ::oEditGroupBox
> do while Len( :aControls ) > 0
> :RemoveControl( :aControls[ 1 ] )
> end do
> end with
>
>
> Regards,
> --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
- ignacio
- Site Admin
- Mensajes: 9447
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Destroying controls?
Chris Gillard escribió el jue, 28 julio 2011 17:47Ignacio,
Thanks for that code.
The loop is reducing the len to aControls to ZERO as it should ... good.
But the Groupbox still has the 'image' of the controls visible.
I have tried GroupBox:Redraw() & GroupBox:Refresh()
Still the 'image' stays.
When new controls are created, I see the new ones and the old ones.
Any thoughts
Try this (have not tested):
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:aControls[ 1 ]:End()
end do
end with
Thanks for that code.
The loop is reducing the len to aControls to ZERO as it should ... good.
But the Groupbox still has the 'image' of the controls visible.
I have tried GroupBox:Redraw() & GroupBox:Refresh()
Still the 'image' stays.
When new controls are created, I see the new ones and the old ones.
Any thoughts
Try this (have not tested):
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:aControls[ 1 ]:End()
end do
end with
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Destroying controls?
Hi Ignacio,
Thanks very much for persevering.
Your code errored with array access on the :RemoveControl( :aControls[
1 ] ) line.
I changed to this and it appears to work. The second loop is probably not
doing anything.
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:aControls[ 1 ]:End()
end do
do while Len( :aControls ) > 0
:RemoveControl( :aControls[ 1 ] )
end do
:Redraw()
:Refresh()
end with
Seems to do what I want.
If you think thats OK I will go with this?
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e31aadb$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris Gillard escribió el jue, 28 julio 2011 17:47
>> Ignacio,
>>
>> Thanks for that code.
>>
>> The loop is reducing the len to aControls to ZERO as it
>> should ... good.
>>
>> But the Groupbox still has the 'image' of the controls
>> visible.
>>
>> I have tried GroupBox:Redraw() & GroupBox:Refresh()
>>
>> Still the 'image' stays.
>>
>> When new controls are created, I see the new ones and
>> the old ones.
>>
>> Any thoughts
>
>
> Try this (have not tested):
>
> with object ::oEditGroupBox
> do while Len( :aControls ) > 0
> :aControls[ 1 ]:End()
> :RemoveControl( :aControls[ 1 ] )
> end do
> end with
>
> --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
Thanks very much for persevering.
Your code errored with array access on the :RemoveControl( :aControls[
1 ] ) line.
I changed to this and it appears to work. The second loop is probably not
doing anything.
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:aControls[ 1 ]:End()
end do
do while Len( :aControls ) > 0
:RemoveControl( :aControls[ 1 ] )
end do
:Redraw()
:Refresh()
end with
Seems to do what I want.
If you think thats OK I will go with this?
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e31aadb$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris Gillard escribió el jue, 28 julio 2011 17:47
>> Ignacio,
>>
>> Thanks for that code.
>>
>> The loop is reducing the len to aControls to ZERO as it
>> should ... good.
>>
>> But the Groupbox still has the 'image' of the controls
>> visible.
>>
>> I have tried GroupBox:Redraw() & GroupBox:Refresh()
>>
>> Still the 'image' stays.
>>
>> When new controls are created, I see the new ones and
>> the old ones.
>>
>> Any thoughts
>
>
> Try this (have not tested):
>
> with object ::oEditGroupBox
> do while Len( :aControls ) > 0
> :aControls[ 1 ]:End()
> :RemoveControl( :aControls[ 1 ] )
> end do
> end with
>
> --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
- ignacio
- Site Admin
- Mensajes: 9447
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Destroying controls?
Chris Gillard escribió el jue, 28 julio 2011 22:02Hi Ignacio,
Thanks very much for persevering.
Your code errored with array access on the :RemoveControl( :aControls[
1 ] ) line.
I changed to this and it appears to work. The second loop is probably not
doing anything.
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:aControls[ 1 ]:End()
end do
do while Len( :aControls ) > 0
:RemoveControl( :aControls[ 1 ] )
end do
:Redraw()
:Refresh()
end with
Seems to do what I want.
If you think thats OK I will go with this?
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e31aadb$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email][/email]
> Chris Gillard escribi� el jue, 28 julio 2011 17:47
>> Ignacio,
>>
>> Thanks for that code.
>>
>> The loop is reducing the len to aControls to ZERO as it
>> should ... good.
>>
>> But the Groupbox still has the 'image' of the controls
>> visible.
>>
>> I have tried GroupBox:Redraw() & GroupBox:Refresh()
>>
>> Still the 'image' stays.
>>
>> When new controls are created, I see the new ones and
>> the old ones.
>>
>> Any thoughts
>
>
> Try this (have not tested):
>
> with object ::oEditGroupBox
> do while Len( :aControls ) > 0
> :aControls[ 1 ]:End()
> :RemoveControl( :aControls[ 1 ] )
> end do
> end with
>
> --
> Ignacio Ortiz de Z��iga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
Crhis,
The second loop is not necessary. BTW, I forgot to delete the 'RemoveControl' code on my first submit, but I did it on a second submit. But only the Web based forum does work correctly with message editions.
Regards,
Thanks very much for persevering.
Your code errored with array access on the :RemoveControl( :aControls[
1 ] ) line.
I changed to this and it appears to work. The second loop is probably not
doing anything.
with object ::oEditGroupBox
do while Len( :aControls ) > 0
:aControls[ 1 ]:End()
end do
do while Len( :aControls ) > 0
:RemoveControl( :aControls[ 1 ] )
end do
:Redraw()
:Refresh()
end with
Seems to do what I want.
If you think thats OK I will go with this?
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e31aadb$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email][/email]
> Chris Gillard escribi� el jue, 28 julio 2011 17:47
>> Ignacio,
>>
>> Thanks for that code.
>>
>> The loop is reducing the len to aControls to ZERO as it
>> should ... good.
>>
>> But the Groupbox still has the 'image' of the controls
>> visible.
>>
>> I have tried GroupBox:Redraw() & GroupBox:Refresh()
>>
>> Still the 'image' stays.
>>
>> When new controls are created, I see the new ones and
>> the old ones.
>>
>> Any thoughts
>
>
> Try this (have not tested):
>
> with object ::oEditGroupBox
> do while Len( :aControls ) > 0
> :aControls[ 1 ]:End()
> :RemoveControl( :aControls[ 1 ] )
> end do
> end with
>
> --
> Ignacio Ortiz de Z��iga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
Crhis,
The second loop is not necessary. BTW, I forgot to delete the 'RemoveControl' code on my first submit, but I did it on a second submit. But only the Web based forum does work correctly with message editions.
Regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Destroying controls?
Ignacio,
Thanks very much for your help on this.
This is a useful technique that I need to remember.
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e326139$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris Gillard escribió el jue, 28 julio 2011 22:02
>> Hi Ignacio,
>>
>> Thanks very much for persevering.
>>
>> Your code errored with array access on the
>> :RemoveControl( :aControls[ 1 ] ) line.
>>
>> I changed to this and it appears to work. The second
>> loop is probably not doing anything.
>>
>> with object ::oEditGroupBox
>> do while Len( :aControls ) > 0
>> :aControls[ 1 ]:End()
>> end do
>> do while Len( :aControls ) > 0
>> :RemoveControl( :aControls[ 1 ] )
>> end do
>> :Redraw()
>> :Refresh()
>> end with
>>
>> Seems to do what I want.
>>
>> If you think thats OK I will go with this?
>>
>> Chris
>>
>>
>> "Ignacio Ortiz de Zúñiga"
>> <nonametoavoidspam@xailer.com> wrote in message
>> news:4e31aadb$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email][/email]
>> > Chris Gillard escribi? el jue, 28 julio 2011
>> > 17:47
>> >> Ignacio,
>> >>
>> >> Thanks for that code.
>> >>
>> >> The loop is reducing the len to aControls to ZERO as
>> it
>> >> should ... good.
>> >>
>> >> But the Groupbox still has the 'image' of the
>> controls
>> >> visible.
>> >>
>> >> I have tried GroupBox:Redraw() & GroupBox:Refresh()
>> >>
>> >> Still the 'image' stays.
>> >>
>> >> When new controls are created, I see the new ones
>> and
>> >> the old ones.
>> >>
>> >> Any thoughts
>> >
>> >
>> > Try this (have not tested):
>> >
>> > with object ::oEditGroupBox
>> > do while Len( :aControls ) > 0
>> > :aControls[ 1 ]:End()
>> > :RemoveControl( :aControls[ 1 ] )
>> > end do
>> > end with
>> >
>> > --
>> > Ignacio Ortiz de Z??iga
>> > [Equipo de Xailer/Xailer team]
>> > http://www.xailer.com
>> > http://www.xailer.info
>
>
> Crhis,
> The second loop is not necessary. BTW, I forgot to delete
> the 'RemoveControl' code on my first submit, but I did it on
> a second submit. But only the Web based forum does work
> correctly with message editions.
> Regards,
> --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info
Thanks very much for your help on this.
This is a useful technique that I need to remember.
Chris
"Ignacio Ortiz de Zúñiga" <nonametoavoidspam@xailer.com> wrote in
message news:4e326139$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Chris Gillard escribió el jue, 28 julio 2011 22:02
>> Hi Ignacio,
>>
>> Thanks very much for persevering.
>>
>> Your code errored with array access on the
>> :RemoveControl( :aControls[ 1 ] ) line.
>>
>> I changed to this and it appears to work. The second
>> loop is probably not doing anything.
>>
>> with object ::oEditGroupBox
>> do while Len( :aControls ) > 0
>> :aControls[ 1 ]:End()
>> end do
>> do while Len( :aControls ) > 0
>> :RemoveControl( :aControls[ 1 ] )
>> end do
>> :Redraw()
>> :Refresh()
>> end with
>>
>> Seems to do what I want.
>>
>> If you think thats OK I will go with this?
>>
>> Chris
>>
>>
>> "Ignacio Ortiz de Zúñiga"
>> <nonametoavoidspam@xailer.com> wrote in message
>> news:4e31aadb$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email][/email]
>> > Chris Gillard escribi? el jue, 28 julio 2011
>> > 17:47
>> >> Ignacio,
>> >>
>> >> Thanks for that code.
>> >>
>> >> The loop is reducing the len to aControls to ZERO as
>> it
>> >> should ... good.
>> >>
>> >> But the Groupbox still has the 'image' of the
>> controls
>> >> visible.
>> >>
>> >> I have tried GroupBox:Redraw() & GroupBox:Refresh()
>> >>
>> >> Still the 'image' stays.
>> >>
>> >> When new controls are created, I see the new ones
>> and
>> >> the old ones.
>> >>
>> >> Any thoughts
>> >
>> >
>> > Try this (have not tested):
>> >
>> > with object ::oEditGroupBox
>> > do while Len( :aControls ) > 0
>> > :aControls[ 1 ]:End()
>> > :RemoveControl( :aControls[ 1 ] )
>> > end do
>> > end with
>> >
>> > --
>> > Ignacio Ortiz de Z??iga
>> > [Equipo de Xailer/Xailer team]
>> > http://www.xailer.com
>> > http://www.xailer.info
>
>
> Crhis,
> The second loop is not necessary. BTW, I forgot to delete
> the 'RemoveControl' code on my first submit, but I did it on
> a second submit. But only the Web based forum does work
> correctly with message editions.
> Regards,
> --
> Ignacio Ortiz de Zúñiga
> [Equipo de Xailer/Xailer team]
> http://www.xailer.com
> http://www.xailer.info