Click here to Skip to main content
15,915,160 members
Home / Discussions / C#
   

C#

 
QuestionStrange Behavior: base.OnPaint [Solved] Pin
Saksida Bojan6-Dec-09 5:48
Saksida Bojan6-Dec-09 5:48 
AnswerRe: Strange Behavior: base.OnPaint [Solved] Pin
Shameel6-Dec-09 23:14
professionalShameel6-Dec-09 23:14 
QuestionSerialization Pin
hadad6-Dec-09 4:26
hadad6-Dec-09 4:26 
AnswerRe: Serialization Pin
Natza Mitzi6-Dec-09 10:02
Natza Mitzi6-Dec-09 10:02 
QuestionDataGridview Drag and drop visualization Pin
anishkannan6-Dec-09 4:25
anishkannan6-Dec-09 4:25 
AnswerRe: DataGridview Drag and drop visualization Pin
Mycroft Holmes6-Dec-09 13:40
professionalMycroft Holmes6-Dec-09 13:40 
QuestionDraw resizeable and draggable rectangle on picturebox to crop image Pin
thungphan5-Dec-09 21:31
thungphan5-Dec-09 21:31 
AnswerRe: Draw resizeable and draggable rectangle on picturebox to crop image Pin
Luc Pattyn6-Dec-09 1:12
sitebuilderLuc Pattyn6-Dec-09 1:12 
Hi,

your code seems pretty clean, although probably too wieldy and not correct.
Unfortunately your text isn't clear, "I tried a few ways but i can't" doesn't even start to describe what is going on.

Here are some thoughts:

1. the code shown describes your Form, so calling Invalidate() will cause the entire Form to be repainted; when you draw on a Control (e.g. a PictureBox), you should invalidate that Control, and make sure it has a paint handler to paint its stuff itself.
What may be happening right now is one of these:
- you Invalidate the Form, it repaints with a rectangle on top of your PB, then the PB itself repaints;
- you Invalidate the Form, it repaints with the exception of the areas taken by its controls, then it does not repaint the controls, as you did not explicitly ask for that to happen (see Invalidate(boolean)).

2.
A PictureBox is a tricky (I would add "and stupid") Control; it knows how to resize the image it holds (SizeMode), however such resizing will not apply to what you draw on top of the PB. For applications like yours I tend to use a Panel, and paint the image myself, in the same paint handler that draws the rectangle, and with the same transformation settings.

3.
You should use mouse handlers that belong to the Control of interest, that would yield coordinates relative to that Control; IMO there probably is no need to call PointToScreen and the like.

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


QuestionUnusual behaviour with Directory.Exists() method Pin
Cracked-Down5-Dec-09 21:21
Cracked-Down5-Dec-09 21:21 
AnswerRe: Unusual behaviour with Directory.Exists() method Pin
N a v a n e e t h5-Dec-09 21:39
N a v a n e e t h5-Dec-09 21:39 
QuestionThe best method for designing a low profile client application Pin
SummerBulb5-Dec-09 21:13
SummerBulb5-Dec-09 21:13 
AnswerRe: The best method for designing a low profile client application Pin
N a v a n e e t h5-Dec-09 21:45
N a v a n e e t h5-Dec-09 21:45 
GeneralRe: The best method for designing a low profile client application Pin
SummerBulb5-Dec-09 22:02
SummerBulb5-Dec-09 22:02 
GeneralRe: The best method for designing a low profile client application Pin
N a v a n e e t h5-Dec-09 22:25
N a v a n e e t h5-Dec-09 22:25 
QuestionRe: The best method for designing a low profile client application [modified] Pin
SummerBulb5-Dec-09 22:38
SummerBulb5-Dec-09 22:38 
AnswerRe: The best method for designing a low profile client application Pin
N a v a n e e t h6-Dec-09 1:54
N a v a n e e t h6-Dec-09 1:54 
AnswerRe: The best method for designing a low profile client application Pin
Daniel Grunwald6-Dec-09 6:42
Daniel Grunwald6-Dec-09 6:42 
AnswerRe: The best method for designing a low profile client application Pin
PIEBALDconsult6-Dec-09 17:08
mvePIEBALDconsult6-Dec-09 17:08 
QuestionNewbie DatagridView Question Pin
kruegersck5-Dec-09 20:56
kruegersck5-Dec-09 20:56 
AnswerRe: Newbie DatagridView Question Pin
OriginalGriff5-Dec-09 21:46
mveOriginalGriff5-Dec-09 21:46 
QuestionConvert string to property name? Pin
BDJones5-Dec-09 18:39
BDJones5-Dec-09 18:39 
AnswerRe: Convert string to property name? Pin
N a v a n e e t h5-Dec-09 18:58
N a v a n e e t h5-Dec-09 18:58 
QuestionRe: Convert string to property name? Pin
BDJones5-Dec-09 19:34
BDJones5-Dec-09 19:34 
AnswerRe: Convert string to property name? Pin
N a v a n e e t h5-Dec-09 19:39
N a v a n e e t h5-Dec-09 19:39 
GeneralRe: Convert string to property name? Pin
BDJones6-Dec-09 5:12
BDJones6-Dec-09 5:12 

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.