Hi, I create (C#) a custom radio button based on the default Windows Forms RadioButton. I paint it in the overridden OnPaint method.
Solution 1: a classic one (I think) is to create (allocate memory) brushes or pens within the OnPaint method, paint stuff and dispose them at the end of the method.
Solution 2: how about creating the brushes only once, as the static members of the class, share them among all instances of the radio button and dispose them by the end of the application life (or maybe even just wait for the application end without explicit disposing).
This is for a small tool-like application, a user would run it, choose an option by a radio button and close the app.
Practically, in both mentioned solutions, the brushes exist all the time the application lives. In solution 1 the brushes are being created and disposed all over again, unnecessary(?), so would static solution 2 be a better idea?
regards
ROB