DynaPDF.CreateComboBox
----------------------

Creates a combo box.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [4.2](newinversion42.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.CreateComboBox"; PDF; Name; Sort; Parent; PosX; PosY; Width; Height ) 

**MBS**( **"DynaPDF.CreateComboBox";** /\* Creates a combo box. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Name**; /\* Name of the fielde.g. "IsMale" \*/   
**$Sort**; /\* If 1, the items are sorted.e.g. 0 \*/   
**$Parent**; /\* Parent group field if any or -1.e.g. -1 \*/   
**$PosX**; /\* X-Coordinate of the text field.e.g. 100 \*/   
**$PosY**; /\* Y-Coordinate of the text field.e.g. 100 \*/   
**$Width**; /\* Width of the text field.e.g. 100 \*/   
**$Height**) /\* Height of the text field.e.g. 20 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Name | Name of the field | "IsMale" |
| Sort | If 1, the items are sorted. | 0 |
| Parent | Parent group field if any or -1. | -1 |
| PosX | X-Coordinate of the text field. | 100 |
| PosY | Y-Coordinate of the text field. | 100 |
| Width | Width of the text field. | 100 |
| Height | Height of the text field. | 20 |

### Result

Returns handle or error.

### Description

Creates a combo box.   
The choice values of the combo box must be added with the function [DynaPDF.AddValToChoiceField](DynaPDFAddValToChoiceField.md). This function requires the field handle that was returned by this function.  
  
A combo box can contain value that is not included in the array of choice values. This value can be used to display a string in the combo box when no choice value is selected, e.g. "Select a value!".  
  
The field value can be set with the function [DynaPDF.SetFieldExpValue](DynaPDFSetFieldExpValue.md) as follows:  
  
The parameter ValIndex of the function [DynaPDF.SetFieldExpValue](DynaPDFSetFieldExpValue.md) must be set to PDF\_MAX\_INT (2147483647) and the parameter Value must contain the whished value or be empty. If Value is empty string, a maybe existing field value will be deleted. The choice values of the combo box get the state unselected when setting a field value in this way.  
  
If the coordinate system is bottom-up the point PosX, PosY defines the lower left corner of the button. If the coordinate system is top-down it defines the upper left corner.  
  
Like all form fields the width and height is measured incl. the line width of the border. The size of normal vector graphics is measured without the line width; this must be taken into account when calculating the width or height of a form field. The line width of the border is derived from the current graphics state (see [DynaPDF.SetLineWidth](DynaPDFSetLineWidth.md)), it should be either 0, 1, 2, or 3 units (no border, thin, medium, or thick). The border style can be changed with the functions [DynaPDF.SetBorderStyle](DynaPDFSetBorderStyle.md) or [DynaPDF.SetFieldBorderStyle](DynaPDFSetFieldBorderStyle.md).  
  
The values of the combo box are sorted if the parameter Sort is 1.  
A combo box requires a font. If no font is active the standard font Helvetica is used. Note: If the form must be compatible to Acrobat 4 the used fonts by the form fields must be restricted to the 14 standard fonts (see SetFont() for further information). Acrobat 4 does not support interactive forms that use other fonts than the 14 standard fonts. Such a form requires Acrobat 5 or higher.  
  
However, it is possible to use an arbitrary font as long as the code page 1252 is used.  
The font size of a combo box is set to "auto" if either the font size of the active font is set to 1.0 unit or if no font is active when the field is created.  
  
Specific flags supported by combo boxes:  
  
| Edit | Enable adding of values in Adobe's Acrobat |
|---|---|
| Sorted | Change the sort flag if necessary |
| CommitOnSelCh | Submit the new value immediately (PDF 1.5) |
| DoNotSpellCheck | Disable spell checking (requires Edit) |

  
Earlier versions of DynaPDF allowed the usage of arbitrary 8 bit code pages. Due to changes in Acrobat viewer applications it is no longer possible to use another code page than 1252. In addition, it seems that Acrobat versions greater 6 do no longer support Type1 fonts in form fields, with the exception of the 14 standard fonts.  
Interactive form fields can be structured into several groups by passing a handle of a group field to the parameter Parent. See [DynaPDF.CreateGroupField](DynaPDFCreateGroupField.md) for further information.  
  
If the function succeeds the return value is the handle of the combo box, a value greater or equal zero. If the function fails it returns an error message.  
See also [CreateComboBox](https://www.monkeybreadsoftware.com/DynaPDF-Manual/CreateComboBox.shtml) function in DynaPDF manual.

### See also

- [DynaPDF.AddValToChoiceField](DynaPDFAddValToChoiceField.md)
- [DynaPDF.CreateCheckBox](DynaPDFCreateCheckBox.md)
- [DynaPDF.CreateGroupField](DynaPDFCreateGroupField.md)
- [DynaPDF.CreateListBox](DynaPDFCreateListBox.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetBorderStyle](DynaPDFSetBorderStyle.md)
- [DynaPDF.SetFieldBorderStyle](DynaPDFSetFieldBorderStyle.md)
- [DynaPDF.SetFieldExpValue](DynaPDFSetFieldExpValue.md)
- [DynaPDF.SetLineWidth](DynaPDFSetLineWidth.md)

### Blog Entries

- [MBS Filemaker Plugin, version 4.2pr5](https://www.mbsplugins.de/archive/2014-05-10/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 18th August 2014

  
[DynaPDF.CreateCheckBox](DynaPDFCreateCheckBox.md) - [DynaPDF.CreateDPartRoot](DynaPDFCreateDPartRoot.md)

[HTML Version](DynaPDFCreateComboBox.shtml)