Hovering Buttons

  • Thread starter Thread starter Zach
  • Start date Start date
Z

Zach

Is it possible to hover a button and by doing so e.g.,
make it chage its color? Apart form a possible "yes",
please give a code example.

Zach.
 
Making a hover button work on a Windows Form application (I assume that is
what you are looking for) you can simply add the following functions:

private void HoverButton_MouseEnter(object sender, System.EventArgs e)
{
if( sender is Button)
{
((Button)sender).BackColor = Color.Red;
}
}

private void HoverButton_MouseLeave(object sender, System.EventArgs e)
{
if( sender is Button)
{
((Button)sender).BackColor = SystemColors.Control;
}
}

Next, you’ll want to wire up the MouseEnter event from your buttons (that
you want affected) to call HoverButton_MouseEnter and their MouseLeave event
to call HoverButton_MouseLeave.

Finally, change the colors specified within those functions to whatever you
want.

Brendan
 
Thank you! Quite simple really, once you find out.
Greetings,
Zach.

Brendan Grant said:
Making a hover button work on a Windows Form application (I assume that is
what you are looking for) you can simply add the following functions:
<snipped>
 
Only the problem is that System.WebUI.WebControls.Button does noy have
definitions for MouseEnter and MouseLeave. Is there a way around?
Zach
 
Back
Top