Run code in Design mode - possible?
Posted on 2009-04-23
is it possible to create a component that can execute some code in design mode?
let's say I have a Panel which holds squares, 3 different sizes 10x10, 100x100 and 200x200... and they are drawn on Panel, depending on the width and height of the panel. For example, if Panel has a height set below 100, then 10x10 squares get drawn, depending on how many can be drawn in width. If Panel is more than 100 in height and width, then squares of 100x100 are drawn... So, the bigger the Panel the more squares are drawn on it, and of course it depends which of the three types of squares are drawn - which fit in.
I hope it's clear enough.
But the developer doesn't really know how many squares will fit in Panel in design mode when resizing and positioning Panel on Form, only when program is run the squares are drawn.
I would like to know if it's possible to create a component that will draw the squares on Panel (Component) in design mode, so the developer will immediately see the result as if it's in runtime mode. So, when the Panel is resized and moved around on the form, it will draw the squares so the developer knows sees exactly how it will look like in runtime.
The squares are drawn on Paint event of Panel.