DrawRectangle problem

  • Thread starter Thread starter Siri Krishna
  • Start date Start date
S

Siri Krishna

Hi,
We have a custom control into which we add controls like labels and move
them at run time. The problem we have is that when a child control is
selected and moved, we draw a rectangle around it to identify it as
selected. The DrawRectangle works fine when the child controls is on left
half of the custom control area but fails to draw the rectangle when moved
to right half of the custom control. When placed some where in between we
see about half rectangle drawn on left side around child control. Does some
body know the strange behavior.
Regards,
Siri
 
I suspect that you're drawing the rectangle in the user controls paint
event. The rectangle is drawn using simple GDI+ commands and is probably
behind something like a panel that is in the user control.

Try converting the coordinates of the rectangle to screen coordinates and
using ControlPaint.DrawReversibleFrame. That draws on the desktop and will
stomp on everything.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top