Home User Manual Discussion Forum Search

Boilerplate Code

Nearly all code starts as a copy of existing code which then gets altered to fit the situation.  We will call the original code the boilerplate code.  It is hard for programmers, especially those not familiar with Open Dental, to find appropriate boilerplate code in the vast sourcecode. It would be easy to pick boilerplate that was too outdated, since we are constantly making improvements to the style, and there is a preferred style for most situations.  Therefore, we have created this page as a resource for boilerplate code.  Please use the code below rather than copying from some other source code file.

Form: Duplicate OpenDental\Forms\BasicTemplate.cs
Detailed instructions: Rename the form. Important: Make sure first that Options\Windows Forms Designer\General\Refactoring=false. Double click on the form to create the Load event.  Move the Load even to always keep OK and Cancel events at the bottom of the code.
Why: Standard button sizes for OK and Cancel.  Translation code added.  Standard look and feel for everyone.

Button: Always use OpenDental.Button rather than System.Windows.Button.  Set the height to 24 pixes even though you will see many buttons using the old height of 26.  Images on buttons should be 20x20 pixels, although most images are still using the old 22x22 standard.
Why: It enables the text on the buttons to be translatable into foreign Languages. The buttons will also resize automatically if foreign text is too long to fit.

Grid: Use ODGrid, either by copying from another form or from the toolbox.  Create a method to fill the grid, usually called FillGrid().  The boilerplate for FillGrid is here: boilerplateGrid.txt.  Add "using OpenDental.UI" at top if necessary.

Table Types: If you add a new table to the database, you'll have to add a new class in OpenDentBusiness\TableTypes.  You must use this boilerplate:  boilerplateTable.cs. You'll also need to add a DataInterface class to OpenDentBusiness.  The "Sites" class is probably the closest boilerplate, although it has a few extra methods that would only be relevant to a table type that gets refreshed upon startup and cached.  For the UI part of the new table, good boilerplate would be FormPharmacies and FormPharmacyEdit.

 

 

 

Open Dental Software 1-866-239-0469