graphics
-
i am developing an app in which i have used graphics object to create and fill a rectangle with some color. now i want to know when the user clicks inside the rectangle but i am getting some problems currently i am doing this with if-elseif conditions wouldn't a much better way to do this is by associating the click event to the rectangle i can't figure out how to associate events with the rectangle is it possible? if yes then please help else tell if there any other way of doing it other than using a label or a picture box end if thanx
TheMrProgrammer
-
i am developing an app in which i have used graphics object to create and fill a rectangle with some color. now i want to know when the user clicks inside the rectangle but i am getting some problems currently i am doing this with if-elseif conditions wouldn't a much better way to do this is by associating the click event to the rectangle i can't figure out how to associate events with the rectangle is it possible? if yes then please help else tell if there any other way of doing it other than using a label or a picture box end if thanx
TheMrProgrammer
Hi, The only UI objects that support events are Controls. Most of them are rectangular, so you are in luck. You could use say a Panel and set its background color. OTOH a Rectangle has a Contains() method which takes a Point, and a MouseEventArg gives you a Point, so you don't have to switch to Controls (which wouldn't make things easy when non-rectangular anyway). :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Hi, The only UI objects that support events are Controls. Most of them are rectangular, so you are in luck. You could use say a Panel and set its background color. OTOH a Rectangle has a Contains() method which takes a Point, and a MouseEventArg gives you a Point, so you don't have to switch to Controls (which wouldn't make things easy when non-rectangular anyway). :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
thanks but whats OTOH
TheMrProgrammer
-
thanks but whats OTOH
TheMrProgrammer
Google for unknown acronyms. OTOH means 'On The Other Hand'
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”