Tuesday, August 14, 2012

Should I develop a custom control or just add it to the form

The definition of "reusable control":
  • The control will be reused in many areas in the same project - for example, "customer group" drop down list which can be reused in many screens within the same project.
  • The control will be used more than once in a project and also useful in other project - for example, DevExpress has developed xtraReport which can be reuse in many projects.
  • The control will be used only once in a project and also useful in other project - for example, you have developed a "main menu" control which reads the menu options from XML file.
In order to speed up the development, testing, implementation and maintenance, you are advisable to come out with a custom control and then drag it into other custom control or Form.

Tricks for using custom control:
  • Drag the custom control on a MDI child Form - in this case, you control will always sit inside the MDI parent window.
  • Drag the same custom control on a non-MDI child Form - in this case, you can shown the control modally.
  • Drag the same custom control into a Tab page control and show it in any Form - now, you custom control will be act like a tab page.
  • Another rare situation is that you instantiate this custom control at runtime and position it to the appropriate location. By doing this, you don't have to mess up the parent control/Form. The coding will be very clean and precise.

No comments:

Post a Comment