jdcoburn
asked on
cannot draw graphics on panel
hi -- I have two panels that are added to a tab control that make up the primary division of my windows form application. The right hand panel (called graph_panel) will draw appropriately when a Graphics object is created, attached to the graph_panel. However, based on a parameter passed to the method, i want to add a child panel (programmatically), create a Graphics object, and put some lines in the child panel. when going into run, the child panel flickers briefly and then whatever is drawn disappears. Does anybody know what limitations there are to creating a child panel as a graphics container?
Is the child panel inside the graph_panel or is the child the left hand panel? I would not be surprised if layering multiple panels would not display properly. You might want to draw the panel (i.e. rectangle) instead of trying to layer two panels.
ASKER
hi --thanks for the comment. i finally got the child panel to work -- i had to call childPanel.Refresh() before i created teh graphics object to draw the line. any idea why that would be the case? it doesn't work if i call refresh after the graphics object is created. what is refresh actually doing?
thanks for any help.
Jim
thanks for any help.
Jim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok -- I suspect a lot of the problem is related to when and how the drawing takes place. I have the main panel.paint event wired to the original method, so that it re-calls the entire drawing process. this works fine for other controls. but it doesn't resize the programmatically added controls, even though i'm using the parent width property. the other anomoly is related to docking. if i programmatically dock, it doesn't work.
i'll try your recommendations and get back to you.
i'll try your recommendations and get back to you.
ASKER
in the for what it's worth category, I was able to solve the problem by using handles to the controls, which allowed me to explicitly control the drawing order and could be passed to the paint method.