3. Adding a title - CodeBlueG/PSForms GitHub Wiki

The first section to add to the form is the title and this is done using the Add-FormTitle cmdlet.

The title sits in the 'header' section of the form and the size and format can be changed. The command line should be made a variable to allow any changes to be made later in the script. Although not strictly necessary for the form title, it is a good habit to keep all of the fields as variables. The cmdlet has the following parameters;

  • FormObject
  • titleText
  • titleFont
  • titleFontSize
  • bold
  • italic
  • underline

FormObject
This is a mandatory field
Enter the name of the form that you are creating, this is the same as the name used in the "Initialize-Form" cmdlet.

titleText
The text that the you wish to show in the title

titleFont
The font that will be used for the title. Note that this font must be available on the target machine

titleFontSize
The size of font used. The default is 18, but can be changed up or down.

bold, italic, underline
These font styles can be applied to the title in any combination. Be aware, in older version of PowerShell, only one of these styles can be applied at a time, it might take some trial and error to ensure that no errors are generated.

Examples

  $lblFormTitle = Add-FormTitle -formObject $TestForm -titleText "Test Form" -underline -bold  

Adds a title "Test Form" that is bold and underlined. (this is tested in PowerShell 4+)
image of form title

  $lblFormTitle = Add-FormTitle -formObject $TestForm -titleText "Test Form" -titleFontSize 14 -titleFont Garamond

Adds a title using no font type with a font of Garamond and size of 14
image of form title