Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Problems with Painting a circle UserControl.
 

Problems with Painting a circle UserControl.

Hello everybody,

I have created a circle control that the end user can add into a custom designer. After loads of work i have now managed to make the control work relatively normal in the designer for example it paints controls that overlap etc.

I now have one remaining issue:

I use a custom control that acts as the designer surface. By default it is white in color and has a grey grid drawn on it. This displays fine on the background of the circle control until i pick the control up to move it within the designer. The background then changes to the background color of the form. Not the designer.

Does anyone have any idea's why this is happening? Is the paint event handled differently if the user has the usercontrol held under the mouse?

I can provide a code sample if it will help solve this issue.

Thanks for any help in advance.

Jamie
jamjam  Friday, January 04, 2008 10:28 AM

Hi,

That happens because the parent of your circle control is still the form. You probably need to add your circle control to your custom designer's Controls collection, this way, your circle control won't inherit the background of the form.

Cheers,

-chris

Chris Vega  Tuesday, January 08, 2008 9:07 AM

Hello,

If you have written your own Paint method, you may need to call Invalidate when it is resized or the location changes. Good Luck!

j2associates  Friday, January 04, 2008 4:10 PM
Hi j2associates,

Thanks for the advice but i have already done this. The issue i am having is when i press and hold the left mouse button so i can move the control. The background of the control randomly changes. In my case its from a white background with a grid drawn on it to a solid white background. As far as i can tell the paint method is rerun at the time of the control being picked up. Its fine when its just at in the designer!

Thanks again,

Jamie
jamjam  Friday, January 04, 2008 4:19 PM

Hi,

That happens because the parent of your circle control is still the form. You probably need to add your circle control to your custom designer's Controls collection, this way, your circle control won't inherit the background of the form.

Cheers,

-chris

Chris Vega  Tuesday, January 08, 2008 9:07 AM

You can use google to search for other answers

Custom Search

More Threads

• Form.designer separated from its form file
• Creating a task list like control.
• Bug (reproducable) with VS2005 Form Designer - release build
• Composite Control and Click Event
• fire form1 event using form2 control
• VS2005 Beta 2 form designer problem: error while parsing EntityName
• Rich Text Box Problem in C#
• Setting DesignerLoader.LoaderHost.RootComponent to an existing Control
• Changing font colors etc at run time using hex input Microsoft Access 2007
• Gradient datagridview columnheader