Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between control.Show and BringToFront?

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

like image 883
spspli Avatar asked Dec 21 '22 14:12

spspli


2 Answers

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

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

Same with Hide() (makes control invisible, but does not change Z-order) and SendToBack (does not change visibility, but brings control to back).

enter image description here

enter image description here

like image 155
Sergey Berezovskiy Avatar answered Feb 22 '23 23:02

Sergey Berezovskiy


These are completly different methods.

Show() : shows the control on the view, by initializing the content of it before.

BringToFront and SendToBack act on Z-order of that control in regard of others. But the control is already visible.

Hints from MSDN on BringToFront:

Brings the control to the front of the z-order.

and on Show:

Displays the control to the user.

like image 24
Tigran Avatar answered Feb 22 '23 22:02

Tigran