Ask a questionAsk a question
 

QuestionDraw on top of child control

  • Friday, November 06, 2009 7:17 PMVS2005_Starter Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    How to draw on top of a child control with another control-

    I have a user control A, that contains usercontrol B and C. C is the last control in the ControlCollection class of A.
    All A, B and C have their own paint events.

    UserControl A contains Usercontrol B. UserControl B contains a Panel and a button.

    UserControl C (a transparent control) is used to represent an invalid state of A. If A is invalid, C is drawn with (X) mark in red color.

    Everything works fine at design time. At run time, C is drawn behind B. I want to draw C on top of B.

    I have tried many combinations, like sending B to back, bringing C to front, calling A.Invalidate in B's paint event etc but with no success.

    Any help is appreciated

All Replies

  • Monday, November 09, 2009 9:10 AMChao KuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,
    Do you mean that you want Usercontrol C appears above usercontrol B?
    I have invested your problem. But on my side, which appears on the top is decided by which is put last. And you could also put C above B, then put B on A, this must result in C on top of B.
    Maybe I misunderstood you, please correct me.
    Thanks
    Chao 
  • Monday, November 09, 2009 6:41 PMVS2005_Starter Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You are correct, I want to UserControl C above usercontrol B.
    In the UserControl A's control collection, C is the last control in the list.
    Still B is drawn on top of C at run time.
    At design time the order is fine. C is drawn on top of B