[.net] Windows Forms Application "Duplicate Widget" Reduction

Started by
1 comment, last by Retlaf 14 years, 9 months ago
Hi, I'm working on a windows forms app to act as a level data editor for my XNA game. My design for this app, however, seems very susceptible to groups of "duplicated widgets" (ie, duplicate code). That is, I have a tab control with 6 or 7 pages, and each one of those pages has a group of the same set of widget types (along with each page also having some unique widgets). From a programmer's perspective, this is really messy. If I ever want to edit the way any of those widgets are laid out, I have to make the same changes to 6 or 7 different places in the application. If I ever want to add some kind of new property to the data that is being edited by those widgets, I have to add the same new control to 6 or 7 different places.. and so on. Is there any way to simplify this design, such that I can declare the group of widgets once, and use multiple instances of this group? Or is this design flawed by nature in the context of forms applications? Thanks!
Advertisement
You can use a UserControl to layout the common controls in one place and then instantiate it in multiple forms.

See here for a thorough overview.
Looks like exactly what I needed. Thanks for the reply!

This topic is closed to new replies.

Advertisement