Patrick

Patrick

  • NA
  • 1
  • 0

Preserving Z-Order in Inheritence

Mar 30 2009 8:55 PM
Hi. I'm having an issue with z-order and inherited objects that I haven't been able to solve through regular searching.
The problem boils down quite simply to: the order of controls seems to be lost on an inherited form.

On a regular form, each object is assigned a position in the z-order based on how you have positioned them.
However if you set the objects' modifier to "protected" (or "public") and inherit the form, the z-order gets forgotten when you start moving things around.

I can't seem to add an attachment to this post so I'll post a very simple set of instructions to reproduce the scenario:

The Problem

  -  Create a form.
       -  Add two objects to the form (eg two picture boxes),
           make one really large and put the second one on top of the first.

       -  In the properties window, change their modifiers to "protected"
  -  Compile the project (ctrl-shift-b)
  -  Right click on your project (in the Solution Explorer),
      select "Add > New Item" from the menu,
      click "Inherited Form," Add, and then OK.
  -  Notice now if you try to reposition the closest picturebox it will strangely
be sent
      to the back of the window. Try moving the other one and it gets sent to the back of
      the window too! This is not regular behaviour. The order should not change when
      you drag objects around in the designer.


Any advise or suggestions would be greatly appreciated.
I need the solution to work correctly from the moment that a new inherited form is created, as many more may be added in the future.


Thanks,
Patrick