What is the difference between control.Show and BringToFront?

What is the difference between Show / Hide and BringToFront / SendToBack? In what situation should we use one pair instead of another?

+4
source share
4 answers

These are completely different methods.

Show() : shows the control in the view, pre-initializing its contents.

BringToFront and SendToBack act on the Z-order this control in relation to others. But control is already visible.

Tips from MSDN on BringToFront :

Leads the control to the z-order front.

and Show :

Displays a user control.

+2
source

Show() equivalent to setting Visible = true . It does not change the control Z-order. If the control is closed by some other control that is in front of the Z-order, the user will still not be able to see your control.

BringToFront() changes the control of the Z-order (brings to the fore), but does not change its visibility. If the control is hidden, it will remain hidden. But when you make your control visible, it will appear in front of all the other controls.

The same is with Hide() (makes the control invisible, but does not change the Z-order) and SendToBack (does not change the visibility, but returns control back).

enter image description here

enter image description here

+7
source

Show / Hide will show or hide the control on the screen. This basically makes it visible or not.

BringToFront / SendToBack will reorder its "z" order. If you have a button under the label and you name "BringToFront" on the button, the button will now hide the label.

+1
source

BringToFront simply moves the control in front of other controls (in other words, it will close another control), and SendToBack will allow other controls to close it, while Show / Hide will actually completely show / hide the control from the user.

Generally you want to show / hide controls

0
source

Source: https://habr.com/ru/post/1441922/


All Articles