How to draw child controls and custom drawings in expected order?

When you need to adjust the z-order of controls on a WinForm, you can use the controls SendToFront and SendToBack methods. A better solution is to go to the control's container. There in the container's Controls property is the SetChildIndex method that can then independently set the z-order of its contained controls.

When you need to adjust the z-order of controls on a WinForm, you can use the controls' SendToFront and SendToBack methods. A better solution is to go to the control's container. There in the container's Controls property is the SetChildIndex method that can then independently set the z-order of its contained controls.

I already use this, for example when I pick the control I put it on front, but the problem is with transparent areas. – Dmitry Polomoshnov Jul 20 at 2:29 The best way then is to draw them manually. – Daniel MoÅ¡mondor Jul 20 at 2:48 Does this mean that I must realize all the functionality, that is built in to winforms, when it comes to fill my containers with textboxes, labels, scrollbar panels, etc?– Dmitry Polomoshnov Jul 20 at 3:49 I don't know about etc, but - labels are simple Graphics.

DrawString, scrollbars will be added as child controls since they are at the edge and aren't 'transparent', you can create ad-hoc textboxes when user will have to input something, and so on. – Daniel MoÅ¡mondor Jul 20 at 6:31 well, I got your point. That's really I suppose to do.

We are dealing with first case here (pic #1). How I should setup my custom control so that instead of parent backround in place of red ellipse there is also part of control that's behind? These are different controls, and I don't want to merge them into one.

I guess I'm clear now. – Dmitry Polomoshnov Jul 20 at 6:57.

I found simple solution to my problem. I've just used Region property of child control (popup) to setup clipping path: GraphicsPath path = new GraphicsPath(); // add some shapes to path here, describing the control shape // ... this. Region = new Region(path); I didn't know about custom path clipping before.

I have control with custom drawings, let's call it Surface. I want to embed some winforms controls into that Surface. 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 Parent. InvokePaint call to draw parent background when needed (and I also tried transparent background). The drawback: when parent background is painted inside child OnPaint event it erases all the other same controls already painted.

The picture below shows the result. Colored areas are the child controls content. I also tried to give the responsibility to draw connectors to Surface and add child controls to Surface.

The drawback: child control are always drawn on top of my custom drawing (which happens in Surface. OnPaint), because their painting happens somewhen later in the queue. I need workable controls inside my Surface (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. How to achieve this?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions