using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mouse_Shaker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void panel1_MouseEnter(object sender, EventArgs e)
{
//Changes Background color of main panel to blue.
panel3.BackColor = Color.Blue;
}
private void panel2_MouseEnter(object sender, EventArgs e)
{
//Changes Background color of main panel to red.
panel3.BackColor = Color.Red;
}
private void panel1_Paint(object sender, EventArgs e) {
}
}
}
so if you couldn't tell from the code, I am trying to get it so that when the mouse enters panel1, panel3 (the main panel) turns blue, and when I enter panel2, panel 3 turns red.
The only problem is that when I run the program, when the mouse enters panel 1 the background turns blue, but when it enters panel 2, nothing happens, and it doesn't matter if it enters panel 2 first or second, it just won't happen. How do I fix this?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Mouse_Shaker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void panel1_MouseEnter(object sender, EventArgs e)
{
//Changes Background color of main panel to blue.
panel3.BackColor = Color.Blue;
}
private void panel2_MouseEnter(object sender, EventArgs e)
{
//Changes Background color of main panel to red.
panel3.BackColor = Color.Red;
}
private void panel1_Paint(object sender, EventArgs e) {
}
}
}
so if you couldn't tell from the code, I am trying to get it so that when the mouse enters panel1, panel3 (the main panel) turns blue, and when I enter panel2, panel 3 turns red.
The only problem is that when I run the program, when the mouse enters panel 1 the background turns blue, but when it enters panel 2, nothing happens, and it doesn't matter if it enters panel 2 first or second, it just won't happen. How do I fix this?
You have not written the code for Mouse exit( Leave). Just write the event for mouse Leave and restore the Panel Color to original Color. Same for the Second Panel. It should solve your problem
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.