Click here to Skip to main content
15,887,985 members
Home / Discussions / C#
   

C#

 
QuestionWhy this change language in multilingual need twice click ? Pin
@Sai_Y23-Dec-18 17:29
@Sai_Y23-Dec-18 17:29 
AnswerRe: Why this change language in multilingual need twice click ? Pin
OriginalGriff23-Dec-18 20:13
mveOriginalGriff23-Dec-18 20:13 
QuestionRe: Why this change language in multilingual need twice click ? Pin
Eddy Vluggen23-Dec-18 21:10
professionalEddy Vluggen23-Dec-18 21:10 
Questionconstraining an ExtenderProvider ... Winform Component Pin
BillWoodruff22-Dec-18 6:48
professionalBillWoodruff22-Dec-18 6:48 
AnswerRe: constraining an ExtenderProvider ... Winform Component Pin
Gerry Schmitz23-Dec-18 8:30
mveGerry Schmitz23-Dec-18 8:30 
GeneralRe: constraining an ExtenderProvider ... Winform Component Pin
BillWoodruff23-Dec-18 12:06
professionalBillWoodruff23-Dec-18 12:06 
QuestionProperties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 20:05
_Q12_21-Dec-18 20:05 
AnswerRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 21:00
mveOriginalGriff21-Dec-18 21:00 
For starters, don't make fields public - use properties instead, and keep fields private.
Public fields mean that the interior workings of your class are exposed to the outside world, and you have to think long and hard before you make any changes at all which might affect them. Properties don't. (And they have other advantages when it comes to being used as a DataSource, serialization, and so forth.)
Secondly, Point is a struct not a class, so you only need to use the new keyword if the constructor needs to be called - it doesn't for Point.
class Human
{
    private string _Name = "none";
    public string Name { get { return _Name; } set { _Name = value; }}
    public Point Location { get; set;}

It's also a bad idea to "mock" events in your class:
public void Paint(object sender, System.Windows.Forms.PaintEventArgs e)
Is not an event handler, so don't make it look like one! )or someone will try to attach a handler, and get confused.
Instead, just pass the data it needs: the graphics context:
public void Paint(Graphics g)
{
    g.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), location.X - 5, location.Y - 15);
    g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(location.X, location.Y, 20, 20));
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
    female.Paint(e.Graphics);
}
That way, it's also easier to call it when you want to draw the name when you enter the control.

Finally - and I think I've mentioned this before recently, but I'm not sure if it's to you: Human is a class, but it isn't derived from Control. Which means it doesn't have any interaction directly with the user, and that includes Mouse events. Adding the line
public event EventHandler MouseEnter;
doesn;t "hook" your class into the "Mouse events" system, it just creates an event called "MouseEnter" which is never raised by anything. If you want a MouseEnter that actually does something then the class which processes it MUST be based on Control: A Form, a Panel, or a UserControl perhaps.
You can't just add a handler and hope the system will sort it all out for you!
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 21:29
_Q12_21-Dec-18 21:29 
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 
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 

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.