Toolbar buttons and title labels

DiverDan

Contributor
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
I have a panel with a toolbar inside it and a title label underneath the toolbar button, also inside the panel. I chose not to title the button directly because the title text shows better in two rows, not one.

Both the title and the toolbar button respond to the user mouse click.

My question is: Is it possible for the toolbar button to react the same (raise) when the mouse enters the title label area? ie:

Private Sub lblTitle_MouseEnter(...) handles lblTitle.MouseEnter
btnToolBarbutton.Select ...where select will show the button as raised.

The above obviously does not work...but what would?

Thanks
 
Code:
Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
        ToolBar1.Buttons(0).Pushed = True '#RAISE THE FIRST BUTTON ON THE TOOLBAR
    End Sub

    Private Sub Label2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label2.MouseEnter
        ToolBar1.Buttons(1).Pushed = True '#RAISE THE SECOND BUTTON ON THE TOOLBAR
    End Sub

    Private Sub Label1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseLeave
        ToolBar1.Buttons(0).Pushed = False '#SINK THE FIRST BUTTON ON THE TOOLBAR
    End Sub

    Private Sub Label2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label2.MouseLeave
        ToolBar1.Buttons(1).Pushed = False '#SINK THE SECOND BUTTON ON THE TOOLBAR
    End Sub
obviously naming the items to your own controls names...
 
Thanks dynamic_sysop,

However, your code sinks the toolbar button. I'm looking for a method to raise the button with the label's MouseEnter event showing the same appearance as if the mouse was over the toolbar button itself.

I personnally cannot find anyway to accomplish this short of showing and hiding a border. :confused:

Here's what I've done:

#Region " lblRealPowerIn"

Private Sub lblRealPowerIn_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRealPowerIn.MouseEnter
BorderVRealPowerIn.Visible = True
BorderHRealPowerIn.Visible = True
End Sub

Private Sub lblRealPowerIn_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRealPowerIn.MouseLeave
BorderVRealPowerIn.Visible = False
BorderHRealPowerIn.Visible = False
End Sub

Private Sub lblRealPowerIn_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblRealPowerIn.MouseDown
btnRealPowerIn.Pushed = True
End Sub

Private Sub lblRealPowerIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRealPowerIn.Click
SetupRealPowerIn()
btnRealPowerIn.Pushed = False
End Sub

#End Region

Where btnRealPowerIn is the toolbar button and lblRealPowerIn is the label.

I am hoping that there is an eaiser, more direct way of doing this.

Thanks
Dan

btw: How soon before your function executes? And how do you program a private function that becomes public during runtime?
 
Last edited:
in label1_MouseEnter i put the following code...

Visual Basic:
ToolBarButton1.Parent.Select()
that raises the toolbar ( subject to it being set to "FLAT" layout )
however making it sink again isnt as easy :S
 
Last edited:
Hi dynamic_sysop,

Okay, that pops the button up very well...and how not so easy is it to reset it back to flat on the mouse leave event?

Thanks
Dan
 
Well if you use a click on label or a click of a button, it stays raised, but if you click down then drag off the label or button ( not lifting the mouse untill you leave the label / button ) then it goes back to normal.
 
Back
Top