Control Visibility Order (One On Top Of Other)

  • Thread starter Thread starter afrinspray
  • Start date Start date
A

afrinspray

Guest
How do I place one element in a form on top of another element (and make sure that it STAYS on top)? For example, if I want to use a picture box in a form, and then I want to put a label over it half-way through the running of a program, how can I be sure that it will always be on top?
:confused:
 
I actually came here to ask the same question basically. I have the user of my program add as many buttons as he wants to a form. So all of my buttons are made programmatically. There is the possibilty that when they choose to make a new button that the new button will be UNDER the older buttons, thus inhibiting the user from changing the location/size of the button because they dont even know where it is.

So my question: If i had a stack of 10 buttons how would I ensure that the button of interest is on top and visible?



afrinspray said:
How do I place one element in a form on top of another element (and make sure that it STAYS on top)? For example, if I want to use a picture box in a form, and then I want to put a label over it half-way through the running of a program, how can I be sure that it will always be on top?
:confused:
 
I don't think there's a way to make that a control will ALWAYS on top of another new cotrol.

Some solution would be call BringToFront method after you create a new control, or create a function that sort all control after you created a new one.

Another one, if you use usercontrol, add a BringToFront method in load method. This will ensure that the control will be on top of other control but only when your created it.
 
I thought I'd post the solution I just found out. It seems the .BringToFront is a function that still works on buttons. For some reason many functions on controls aren't showing up in the list you get after you type a period.. this is irritating to say the least.
For instance
typing "Button1." brings up a list of all the functions and properties of that button that you can use on it. But many usable functions are not on there! BringToFront is one of those functions and it works perfectly for what I needed to be done.

Does anyone know why all of the functions available to a control do not show up after "Button1." ?

Edit: It might be because I added the buttons programmatically.

michaelrawi said:
I don't think there's a way to make that a control will ALWAYS on top of another new cotrol.

Some solution would be call BringToFront method after you create a new control, or create a function that sort all control after you created a new one.

Another one, if you use usercontrol, add a BringToFront method in load method. This will ensure that the control will be on top of other control but only when your created it.
 
Last edited:
ya the control was in scope. Somethings are just somtimes not listed, i'm not sure why.

Cags said:
The intellisense should still work regardless of whether you added the control programatically, assuming the control is in scope.
 
VB Express has a feature I am not particularly fond of. It has two tabs in the intellisense. Make sure you are looking at the second tab, which lists all memebers as opposed to "commonly used members," which the first tab lists.
 
NeuralJack said:
I thought I'd post the solution I just found out. It seems the .BringToFront is a function that still works on buttons. For some reason many functions on controls aren't showing up in the list you get after you type a period.. this is irritating to say the least.
For instance
typing "Button1." brings up a list of all the functions and properties of that button that you can use on it. But many usable functions are not on there! BringToFront is one of those functions and it works perfectly for what I needed to be done.

Does anyone know why all of the functions available to a control do not show up after "Button1." ?

AFAIK, Intellisense will display all control's functions and methods (It's hasn't change from VB6). Maybe you've declare a control with different name (example you created butProces, but you tried to call butProcess ??. Sometimes, it get me too).

NeuralJack said:
Edit: It might be because I added the buttons programmatically.

No. It's always the same. Even if you add your button programmatically, at least you have to declare it first (dim blabla as new window.forms.button). So, IDE will sure know that you've declare an object.
 
What will have an effect on what intellisense shows is what the variable is declared as. If you store a Button in an Object variable, the compiler doesn't know that (and Button methods are not available without a cast) so intellisense will only show members of System.Object. If you declare the variable as Control you will see only Control-specific members.
 
Back
Top