Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:25:09+00:00 2026-05-28T18:25:09+00:00

I use C#, VisualStudio 2010 and I created a custom UserControl for a Windows

  • 0

I use C#, VisualStudio 2010 and I created a custom UserControl for a Windows Forms application. They don’t have much behavior apart from displaying themselves and allowing themselves to be dragged elsewhere. However they are circular in shape and I cannot display them correctly when they overlap on the corners.

Here is my code for painting them on the screen:

  public void Circle_Paint(object sender, PaintEventArgs e)
  {
     var g = e.Graphics;

     g.FillEllipse(brushForOuterCircle, 0, 0, Width, Height);
     g.FillEllipse(brushForInnerCircle, lineWidth, lineWidth, Width - 2*lineWidth, Height - 2*lineWidth);

     if(!textLocation.HasValue)
     {
        SizeF m = g.MeasureString(text, textFont);
        textLocation = new PointF((float)((Width - m.Width)/2.0), (float)((Height - m.Height)/2.0));
     }
     g.DrawString(text, textFont, brushForText, textLocation.Value);
  }

Here is an example of incorrect display, the southeast part of the AB circle does not display because CD overrides that area.

enter image description here
How should I prevent that, is there a way to tell the UserControl “you are transparent by default; any portion I don’t draw onto should remain so” ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:25:11+00:00Added an answer on May 28, 2026 at 6:25 pm

    Try to:

    setup on your user control first WS_EX_COMPOSITED extended style, by overriding

    protected override CreateParams CreateParams
    {
       get
       {
         CreateParams cp = base.CreateParams;
         cp.ExStyle |= 0x00000020; // add this
         return cp;
       }
    }
    

    after do not paint anything in background by

    protected override void OnPaintBackground(PaintEventArgs e)
    {
       // leave this empty 
    }
    

    and finally in Paint draw your shape.

    Should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one Windows Forms application with C# and MySQL (using MySQL Connector
I have several forms in a C# application. I use Visual Studio 2010 Beta,
In Visual Studio 2010 I have created a WebService (WCF) Application and a client
I'm having some trouble with VisualStudio 2010 C# Winforms. I have created a DataGridView
I have created a Windows Service, and an associated installer using Visual Studio 2010.
I have created a sample web application in Visual Studio 2010. It stores Membership
I have a prob. I'm trying to create a custom slugify functiom. I use
I have 5 entity and use the custom model for the three of them
I have created a program in Visual Basic using Microsoft Visual Studio 2010 Professional.
I have to create an application using a Datalogic mobile device that uses Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.