Results 1 to 5 of 5

Thread: How to change a control's Z-Property?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    108

    Smile How to change a control's Z-Property?

    Hi,

    How do I change an Imagebox's Z-Property?

    Currently, on the vb.net form, there are a few Imagebox controls. By default, the Imageboxe added later will block the rest of the imageboxes when they are placed on top of each other.

    e.g Imagebox3 will block Imagebox1 when they are placed on the same position in the form.

    Currently there are 4 imageboxes on the form. How do I make Imagebox3 block the rest of the imageboxes and for imagebox4 to block out imageboxes 1 and 2?

    Is it possible to change each control's z-property individually?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to change a control's Z-Property?

    Z-Index?

    I think there's a ZOrder method, or I might be spouting bilge.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to change a control's Z-Property?

    It isn't possible to set a contol's position in the z-order explicitly. All you do is call BringToFront or SendToBack on each control in the appropriate order and they will be stacked accordingly. You can do this at run time or you can do it at design time by right-clicking on the control in the design window.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    108

    Re: How to change a control's Z-Property?

    So I'll use something like this:

    Imagebox3.BringToFront() 'Covers all the imageboxes
    Imagebox4.BringToFront() 'Covers all the imageboxes except for Imagebox3

    Is it correct?

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to change a control's Z-Property?

    Wrong. If you call BringToFront on Imagebox3 then it will be brought to the front, so in front of every other control. If you then call BringToFront on Imagebox4 then it will be brought to the front of evey other control including Imagebox3. If you call BringToFront on every control the the first one you call it on will be at the back and the last one will be at the front. The opposite is true of SendToBack. Just imagine that the controls are a pack of cards. If you bring each of the 52 cards to the front, one after the other, then the first one would be end up the back.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width