HOW TO: set a border property on a field

This is for my own freaking edification because there is nothing on the forum and nothing in the documentation about how to do this and I have to search my own solution each time for the answer when it should be a simple google search away for everyone…

Three parameters should be defined when setting the border property to a field: the kind of border, the thickness, and the color.

These should be enclosed in quotes because they are passed as a string.

so…

element.setBorder.('LineBorder,1,#ff0000')

I’ve specified that the border of my field should be a line ( because really a border could could be any number of things: Etched, Line, SpecialMatte, etc) , it should have thickness of 1 (this can be done in whole integers) and it should have the color blood red because I like my near sighted and color blind users to know that there’s an issue with this field and that they haven’t done something correctly. (Users… who need 'em).

Oh, and if you want to set a border to empty ( I’ve read this should be done on an onShow but I’ve successfully tested it elsewhere), here’s how:

elements.setBorder("EmptyBorder,0,0,0,0")

Sardonic diatribe ends now…

A suggestion to Paul Bakker: The exact syntax of all the types of borders should be in the wiki.

In the mean time you can also find out the border format by setting format you want on a field using Servoy Developer and copy the string from the .frm-file.

borderType:"TitledBorder,Hello,2,2,DialogInput.plain,0,11,#0000ff"

Rob

In Servoy 5.1, the code and sample helpers need work, too! The helper says:

void setBorder(spec)

but when you copy the sample code, it presents the following example:

var b = elements.elementName.setBorder(‘Line,1,1,#ccffcc’);

Note, one has an unknown return type and the other a return type of ‘void’.

Also, the sample helper show a specification of ‘Line,1,1,#ccffcc’ that does not work and should be ‘LineBorder,1,1,#ccffcc’.

I hope this helps!