Hovering Buttons

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.
 
G

Guest

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
 
Z

Zach

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>
 
Z

Zach

Only the problem is that System.WebUI.WebControls.Button does noy have
definitions for MouseEnter and MouseLeave. Is there a way around?
Zach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top