I’m fairly new to Visual C# and I’m trying to create a List<String> whose contents are shown by a form widget, preferably using the form editor. Coming from a Qt/C++ background I usually do something like this:
- Create a custom data structure in my Model that wraps around a
QList<string>and derives from theSubjectclass in the Observer pattern. - Create a new widget that subclasses from
Observer(which again is part of the Observer pattern) and one of Qt’s list widgets. This newly created widget should be able to update the list when it receives a notification from the data structure. - Make sure that the widget subscribes to the data structure at runtime.
This procedure is a pain in the butt and I’m sure that there’s a better way, but I’m not here for Qt help right now. What’s the quickest way to display the contents of a List<String> (or similar structure) in C#? I’m using WinForms.
1 Answer