How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back?
How to get a button to send to front/send to back? How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
Go Back  Xtreme Visual Basic Talk > > > How to get a button to send to front/send to back?


Reply
 
Thread Tools Display Modes
  #1  
Old 01-30-2014, 06:29 PM
Distinguished Distinguished is offline
Newcomer
 
Join Date: Jan 2014
Posts: 1
Default How to get a button to send to front/send to back?


Hello.

How to get a button to send to front/send to back?

I am trying to put one label on top of another, and have the press of a button send the top one to the back, making the one underneath visible. Would appreciate any help.

I am extremely new to VB, so please break it down in layman's terms.

Thanks!!!

(Don't know if it matters, but I'm using VB 2010.)

Last edited by Distinguished; 01-30-2014 at 07:02 PM.
Reply With Quote
  #2  
Old 01-31-2014, 09:12 AM
Flyguy's Avatar
FlyguyHow to get a button to send to front/send to back? Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,165
Default

Please don't reply to threads which are inactive for more than 30 days, in this case the thread is more than 10 years old.

Also VB.NET is not the same as VB6, so moved to a different sub forum.
Reply With Quote
  #3  
Old 01-31-2014, 12:11 PM
passel's Avatar
passelHow to get a button to send to front/send to back? passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Assuming you Label1 and Label2 on top of each other, you would use something like
Label1.SendToBack() 'to reveal Label2
Label2.SendToBack() 'to reveal Label1

If you want a single button to toggle the position then you might want another variable to track which "state" your buttons are in so you know which to send to the back.
If you needed to check that variable to see which is on top, then rather than be static in the button click method, declare it at the Form class level, as Private rather than Static.
Code:
Public Class Form1

  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    'Label2OnTop (in Button1_Click) will be false initially, so toggle to True the first time, which will send Label1 to the back
    'so, let's make sure Label1 is on top initially, by sending Label2 to the back at startup.
    Label2.SendToBack()
  End Sub

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Static Label2OnTop As Boolean
    Label2OnTop = Not Label2OnTop
    If Label2OnTop Then
      Label1.SendToBack()
    Else
      Label2.SendToBack()
    End If
  End Sub

End Class
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back? How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back? How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
 
How to get a button to send to front/send to back?
How to get a button to send to front/send to back?
 
-->