Click here to Skip to main content
16,006,535 members
Home / Discussions / C#
   

C#

 
GeneralRe: newbie in c# Pin
yaminilathatv15-Dec-05 22:27
yaminilathatv15-Dec-05 22:27 
GeneralRe: newbie in c# Pin
J4amieC16-Dec-05 0:25
J4amieC16-Dec-05 0:25 
GeneralRe: newbie in c# Pin
yaminilathatv16-Dec-05 21:55
yaminilathatv16-Dec-05 21:55 
QuestionSchema Pin
Mahi.Ragava15-Dec-05 18:00
Mahi.Ragava15-Dec-05 18:00 
QuestionCheckbox Arrays... Pin
flicktom15-Dec-05 17:48
flicktom15-Dec-05 17:48 
AnswerRe: Checkbox Arrays... Pin
flicktom15-Dec-05 18:26
flicktom15-Dec-05 18:26 
AnswerRe: Checkbox Arrays... Pin
J. Dunlap15-Dec-05 18:26
J. Dunlap15-Dec-05 18:26 
QuestionHit testing problem Pin
t800t815-Dec-05 15:44
t800t815-Dec-05 15:44 
I need to write a program which can draw rectangle by mouse. User can draw a rectangle by click left mouse button and drag mouse, when user release left mouse button, rectangle will be drawn.

I can draw rectangle, but now I want to check when I move mouse, program can show me the mouse is inside a rectangle or not.

I use an RectangleArray which inherits from CollectionBase to store all drawn rectangle. In mouse move method, I loop through this array and use Contains method of Rectangle class to check the mouse inside or not.

But I don't understand while I only can check the position of mouse if it is inside the first rectangle I drawn (label4 only change value when I move the mouse inside the first rectangle). If I show a message box, label4 can change its value when I move the mouse inside any rectangle.

private void picImage_MouseMove(object sender, MouseEventArgs e)
{

	Point mousePoint = new Point(e.X, e.Y);

        foreach (Rectangle rect in rects)
        {

                if (rect.Contains(mousePoint))
                {
               		label4.Text = "In rect";
               		//MessageBox.Show(label4.Text);
               		break;
	        }
               	else
               	{
               		label4.Text = "Not in rect";
               	}

       	}

}


Can anybody help me? Thanks a lot!

I'm ...
a fan of Manchester United
a fan of Ozzy Osbourne
a King of Nothing
AnswerRe: Hit testing problem Pin
Heath Stewart15-Dec-05 21:35
protectorHeath Stewart15-Dec-05 21:35 
GeneralRe: Hit testing problem Pin
t800t815-Dec-05 22:01
t800t815-Dec-05 22:01 
Question[URGENT] REGEX question Pin
Sam 200615-Dec-05 15:20
Sam 200615-Dec-05 15:20 
AnswerRe: [URGENT] REGEX question Pin
Christian Graus15-Dec-05 16:12
protectorChristian Graus15-Dec-05 16:12 
Questionopen an executable file on remote machine using WMI Pin
Erick Shuai15-Dec-05 15:12
Erick Shuai15-Dec-05 15:12 
AnswerRe: open an executable file on remote machine using WMI Pin
Dave Kreskowiak15-Dec-05 16:22
mveDave Kreskowiak15-Dec-05 16:22 
QuestionExists an interface for Parse(string value) method and ToString(string format)? Pin
machocr15-Dec-05 14:21
machocr15-Dec-05 14:21 
AnswerRe: Exists an interface for Parse(string value) method and ToString(string format)? Pin
[Marc]15-Dec-05 14:46
[Marc]15-Dec-05 14:46 
GeneralRe: Exists an interface for Parse(string value) method and ToString(string format)? Pin
machocr15-Dec-05 17:31
machocr15-Dec-05 17:31 
GeneralRe: Exists an interface for Parse(string value) method and ToString(string format)? Pin
S. Senthil Kumar15-Dec-05 20:45
S. Senthil Kumar15-Dec-05 20:45 
GeneralRe: Exists an interface for Parse(string value) method and ToString(string format)? Pin
machocr16-Dec-05 10:47
machocr16-Dec-05 10:47 
QuestionATTACHING DATABASE FILE Pin
Bagie15-Dec-05 14:08
Bagie15-Dec-05 14:08 
AnswerRe: ATTACHING DATABASE FILE Pin
Curtis Schlak.15-Dec-05 15:21
Curtis Schlak.15-Dec-05 15:21 
GeneralRe: ATTACHING DATABASE FILE Pin
Bagie16-Dec-05 12:52
Bagie16-Dec-05 12:52 
GeneralRe: ATTACHING DATABASE FILE Pin
Curtis Schlak.17-Dec-05 4:34
Curtis Schlak.17-Dec-05 4:34 
GeneralRe: ATTACHING DATABASE FILE Pin
Bagie17-Dec-05 11:12
Bagie17-Dec-05 11:12 
GeneralRe: ATTACHING DATABASE FILE Pin
Curtis Schlak.19-Dec-05 18:06
Curtis Schlak.19-Dec-05 18:06 

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.