Container control refresh issue

I have a container control that I have written that does custom drawing of it's background.

If I resize the control in any way, it redraws correctly, but if I so much as select a control that is in the container while in design time, it doesn't redraw properly in that it will leave black areas around where the focus box and grab handles were. If you move the child control it will leave a black spot where it was. Resizing refreshes it correctly though.

Any ideas how to force the control to refresh itself when a child control is moved around at design time


Answer this question

Container control refresh issue

  • shobhit

    Ah!!! thanks! That was it. I thought it would be in the System.Windows.Forms namespace...
  • sumana

    hrm... Well, one option would be to create a designer for your class derived from ScrollableControlDesigner and use HookChildControls along with GetHitTest.  You can find an example <a href="http://www.dotnet247.com/247reference/msgs/5/27224.aspx">here</a>.



  • almor

    Do you have a reference to System.Design.dll 
  • Christian Szabo

    Well, it is, kind of... It's just in a different dll.  In the future, though, you can find out which DLL you need to reference by pulling up the help and navigating to the About page for a given class (in this instance, the index entry would be ControlDesigner -> About Control Designer Class).  At the bottom of that page will be a requirements section that looks like this:

    <b>Namespace:</b> System.Windows.Forms.Design

    <b>Platforms:</b> Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family

    <b>Assembly:</b> System.Design (in System.Design.dll)

    The last line tells you what DLL you need to have a reference to.

  • d72e4d

    Ya, I just noticed... didn't look, stupid me.... oh well, thanks for your help!  I've almost got all of the draw issues out except for the last move. On the last move, it leaves the focus rect without redrawing it from where the control was before it was moved.

    It does clear out all past moves now though.

    Any ideas

  • Sasha

    Thanks for the sample!

    I have one problem:

    System.Windows.Forms.Design.ControlDesigner doesn't exist according to the compiler and it isn't there in intellisense either.

    (VS.net 2003)

    The help says it should be there but it just isn't no matter what I do.

    Any ideas

  • Container control refresh issue