The Daily WTF
If you create a UI object in code, you have to go through all that pesky, annoying work of initalizing that object so it displays correctly. I mean, who wants to write VB.NET code which looks like this:
Label = New Label Label.Size = New Size(710, 300) Label.TextLB = “Operation:” someForm.Controls.Add(Label)
Here, we’ve created a label object which overrides a handful of default properties, and then gets added to the screen. You’ll have to do that for every control! Obviously, you need a method.
No, not a method called something like OperationLabel() which creates and adds the Operation: label to the form. You have to think more generic than that. We want a method which allows us to add any label, with any configuration, to the form.
Benjamin‘s co-worker has an idea exactly about how to accomplish that. Instead of that ugly block of code above, you can
To read the full article click on the 'post' link at the top.