Draw Panel

  • Thread starter Thread starter Eric Seneca
  • Start date Start date
E

Eric Seneca

Hello,

I am trying to draw a series of panels on a graphic object. I am new to
drawing object programmically and was wondering if anyone knew of a good
tutorial that would show me how to control the objects on the screen.
Any guidance would be appreciated...

Eric
 
Tim said:
Are you referring to actual painting using a Graphics object or dynamically
creating controls, such as the Panel control, and adding them to a
container?

If your inquiring about custom painting then see if this helps clear some
things up.
http://www.awprofessional.com/articles/article.asp?p=336257&seqNum=2&rl=1
i am trying to actually create the control and not paint things on the
screen. Say create a panel inside a picturebox on a form...

Eric Seneca
 
So you're looking to create a control and add it to another control as a
child? If you look at the InitializeComponent method that is controlled by
the designer you can see how controls are created and added as children to
other controls. Although I don't believe that the PictureBox is an allowable
container. In other words, if you attempt to add a control to the Controls
collection of a PictureBox I believe you will be met with an exception.
 
Tim said:
So you're looking to create a control and add it to another control as a
child? If you look at the InitializeComponent method that is controlled by
the designer you can see how controls are created and added as children to
other controls. Although I don't believe that the PictureBox is an allowable
container. In other words, if you attempt to add a control to the Controls
collection of a PictureBox I believe you will be met with an exception.
humm i see what you are saying to get aroudn this i set a picture box
and create panels dynamically via code and set the parent of that code
to the actualy form the picture boxe is on. The i bring the panel to the
front with a color and i have it in the contain frmMain...

Thanks..
 
That's one way to do it, yes. Another way would be to use a Panel instead of
a PictureBox and, since I assume that you were setting an image to be
displayed through the PictureBox, painting the image yourself through the
Panels Paint event. Then you could add the child Panels to the Panel that is
custom painted. This way if you ever needed to move the parent Panel then
you know that the child Panels will automatically follow and you won't be
required to move them as well, as will be case if you parent these Panels to
the Form.
 
Back
Top