Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to draw child controls and custom drawings in expected order?
    text
    copied!<p>I have control with custom drawings, let's call it <code>Surface</code>.</p> <p>I want to embed some winforms controls into that <code>Surface</code>. But also I want to draw some custom drawings (connectors), depending on controls location, size, etc.</p> <p>I tried to give the responsibility to draw those connectors to child controls themselves, so any of my child control was just bigger in size and included all the necessary drawings. I used <code>Parent.InvokePaint</code> call to draw parent background when needed (and I also tried transparent background). </p> <p><strong>The drawback</strong>: when parent background is painted inside child <code>OnPaint</code> event it erases all the other same controls already painted. The picture below shows the result. Colored areas are the child controls content.</p> <p><img src="https://i.stack.imgur.com/AgojS.png" alt="enter image description here"></p> <p>I also tried to give the responsibility to draw connectors to <code>Surface</code> and add child controls to <code>Surface.Controls</code> list. </p> <p><strong>The drawback</strong>: child control are always drawn on top of my custom drawing (which happens in <code>Surface.OnPaint</code>), because their painting happens somewhen later in the queue.</p> <p><img src="https://i.stack.imgur.com/2ifwg.png" alt="enter image description here"></p> <p>My requirements are:</p> <p>I need workable controls inside my <code>Surface</code> (receiving any mouse and keyboard event, focusable, etc). Every control would have some custom-drawn connectors to show context on surface. And when controls are overlapped I want everything to appear in expected order.</p> <p>How to achieve this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload