I am working on a WordSearch voice program (also called WordFind) where you need to find specific words in a mass of letters. I am using C # WinForms.
My problem is when I want to click and hold 1 letter ( Label ) and then drag it to other letters to change their ForeColor . I tried searching the Internet, but to no avail.
Here is what I have:
foreach (Letter a in game.GetLetters()) { this.Controls.Add(a); a.MouseDown += (s, e2) => { isDown = true; a.ForeColor = Color.Yellow; }; a.MouseUp += (s, e2) => { isDown = false; }; a.MouseHover += (s, e2) => { if (isDown) a.ForeColor = Color.Yellow; }; }
However, the MouseHover event never fires if the mouse is not held. Also no luck changing MouseHover with MouseEnter . So, I saved the MouseDown and MouseUp and tried to use MouseHover in the form itself:
private void frmMain_MouseHover(object sender, MouseEventArgs e) { if (isDown) { foreach (Letter l in game.GetLetters()) if (l.ClientRectangle.Contains(l.PointToClient(Control.MousePosition))) l.ForeColor = Color.Purple; } }
This event also does not work, and I do not understand why he is not shooting and what alternative solutions are. Any advice is appreciated.
source share