You can also programmatically add event hooks. You can write your event handler, so in this case the shell is
private void panel_Paint(object sender, PaintEventArgs e)
{
}
Then, whenever you add a new panel to the form, you add an event handler to that panel like so:
Panel newPanel = new Panel();
newPanel.Paint += new PaintEventHandler(this.panel_Paint);
this.Controls.Add(newPanel);
Then, whenever your new panel is painted, it will go to your handler.
There's an example
here[
^]