Search code examples
c#winformsformsmultiple-forms

When should a second form in a winform application be populated?


I am creating a windows form application in C# and I have two forms. The main form where the user is going to be working with a graph and another form that contains: series appearance options, axes options, label options, etc... This form appears when the "Tool" button is pressed. From there I intend to let the user modify their graph as they wish. My question is- Is it faster/better to populate the second form when the first form loads or initializes, or should it just do that when the "Tool" button is pressed.


Solution

  • This question is about a difference between eager loading (load data as soon as possible) and lazy loading (load data when it is necessary). I think the decision here should come down to user experience. If the data takes a little while to load and your users will be accessing the properties window frequently then I would suggest eager loading. If on the other hand the loading is quick or this is a feature that is going to be infrequent then I would suggest lazy loading. So, you need to figure out what your users expect. But, if the data for the screen loads quickly then it hardly matters what you load when.

    I would also suggest that you rethink your properties window, especially if it is going to be used frequently. The paradigm for this kind of user interface has been to embed a PropertyGrid into the same application window where the bulk of the work is done. Think about Visual Studio for many, many examples and just about any IDE-style application. They do not tend to have "floating" properties windows. The paradigm is that you show the properties of whatever object is currently selected in the IDE to allow quick and easy modification. The separate Tools | Options paradigm is more for application-level settings that are modified much less frequently and are tied to the app at large rather than particular objects that the application manages. Again, Visual Studio is a good example.