Swapping Two Controls

Hi -

I have an application that requires a combo box in some situations, and a text control in others. What I’d like is to be able to switch the controls from my application, but all my attempts at this place the replacement control top-left of the parent, instead of where the original control was.

What is the best way to do this?

Cheers!
Greg Fawcett.

···


Phone: +64 3 409 8165
Mobile: +64 21 333 291
Fax: +64 3 974 6810
Web: www.vig.co.nz

You have probably forgotten to add the new item to the proper sizer.

What I have done in the past is to add the two controls at the same
time (if you are using a grid sizer, add a little box sizer with both
controls in it), then depending on which one I want to see, .Show(1)
on the one I want to see, .Show(0) on the one I don't, then .Layout()
on the parent to force a layout. From there it's just logic to decide
which control you want to get data from.

- Josiah

···

On Wed, Jun 25, 2008 at 10:51 PM, Greg Fawcett <greg@vig.co.nz> wrote:

Hi -

I have an application that requires a combo box in some situations, and a
text control in others. What I'd like is to be able to switch the controls
from my application, but all my attempts at this place the replacement
control top-left of the parent, instead of where the original control was.

What is the best way to do this?

Thanks - I tried putting both in a sizer early on, but didn’t have the Layout() call. Later I tried the Layout() call, but was calling it on the frame, not the panel the controls were on, and by that stage I had got rid of the sizer and was trying to replace objects directly. Easy when you know how!