0
Reply

Parent and child custom controls

James

James

18 years ago
1.4k
Hi Everyone, I have a question about the correct way to create a custom control that contains a dynamically controlled number of child controls. Basically i'm trying to implement a basic vector drawing control similar to that found in photoshop/xara/inkscape etc. I have a parent "vector" control that containes a number of "point" controls and "line" controls (where the lines connect the points). I figured this was the best way to do it so I could handle events on each part of the vector itself easily.

The problem I have is with the OnPaint(PaintEvenArgs e) overrides. I seem to be able to add my child controls ok, and the OnPaint() functions are definately called for each child control, the problem is that after the first child control is finished e.graphics seems to be set to some arbitrary value for all other control's events. Because of this, cliprect is set to 0 and all controls except the first are drawn.

I was wondering if someone could point me to a good example/tutorial of what im trying to do (i cant seem to find one anywhere), or maybe give me some hints as to what i'm doing wrong...

I have pasted some relevant code below, just in case anyone is interested.

Thanks in advance,
James

P.S. I couldn't figure out a way to format the code in this forum, so please check This post for the code.