Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 21:42
mveOriginalGriff21-Dec-18 21:42 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 21:48
_Q12_21-Dec-18 21:48 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 21:50
mveOriginalGriff21-Dec-18 21:50 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 22:01
_Q12_21-Dec-18 22:01 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 22:20
mveOriginalGriff21-Dec-18 22:20 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 22:37
_Q12_21-Dec-18 22:37 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:08
mveOriginalGriff21-Dec-18 23:08 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 22:33
mveOriginalGriff21-Dec-18 22:33 
I tell you what: stop what you are doing.
Create a new solution, WinForms, call it "HumanDemo"
Add a UserControl to the project, call it Human.
In the designer, add event handlers to the Human control: MouseEnter, MouseLeave, Paint.
In the Human code, add a field and a property:
private bool isIn = false;
public string Name { get; set; }
In the Human Constructor, add a line, so it looks like this:
public Human()
    {
    InitializeComponent();
    Name = "A name";
    }
Then edit the three handlers so they look like this:
private void Human_MouseEnter(object sender, EventArgs e)
    {
    isIn = true;
    Invalidate();
    }

private void Human_MouseLeave(object sender, EventArgs e)
    {
    isIn = false;
    Invalidate();
    }

private void Human_Paint(object sender, PaintEventArgs e)
    {
    Graphics g = e.Graphics;
    Rectangle rect = e.ClipRectangle;
    rect.Inflate(-1, -1);
    g.DrawRectangle(Pens.Red, rect);
    if (isIn)
        {
        g.DrawString(Name, Font, Brushes.Black, new Point(10, 10));
        }
    }
Compile your project.
Go to the main form in teh designer, and drag a Human control from your toolbox and drop it on the form.

Run your application. Move the mouse into and out of the red rectangle.

That's how simple it is!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 22:47
_Q12_21-Dec-18 22:47 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:04
mveOriginalGriff21-Dec-18 23:04 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 23:09
_Q12_21-Dec-18 23:09 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:14
mveOriginalGriff21-Dec-18 23:14 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 23:22
_Q12_21-Dec-18 23:22 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:23
mveOriginalGriff21-Dec-18 23:23 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 23:28
_Q12_21-Dec-18 23:28 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 23:28
_Q12_21-Dec-18 23:28 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:52
mveOriginalGriff21-Dec-18 23:52 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 4:37
_Q12_22-Dec-18 4:37 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff22-Dec-18 4:51
mveOriginalGriff22-Dec-18 4:51 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 5:43
_Q12_22-Dec-18 5:43 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 6:08
_Q12_22-Dec-18 6:08 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 6:16
_Q12_22-Dec-18 6:16 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff22-Dec-18 6:19
mveOriginalGriff22-Dec-18 6:19 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 6:41
_Q12_22-Dec-18 6:41 
Questionhow to hide a column in excel through C# Pin
Member 1204584621-Dec-18 0:39
Member 1204584621-Dec-18 0:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.