I am creating multiple forms that are going to have a ListView populated with the same data. So I figured instead of populating the data separately in each form, I’ll create a derived ListView and put the data population in the constructor.
The problem that I’m having is when I add the control to a form with the designer it is adding hard-coded ListViewItems to the ListView in the designer file. Therefor when the app is actually run it’s creating duplicate items.
I know WHY this is happening but I would like to find a way to prevent it.
Thanks for any help.
I found a solution to my problem after some more research.
What I needed was a way to only execute my code when “DesignMode” is false.
Since DesignMode is always false in the constructor I put in an override to the OnCreateControl event and put it in there: