ChoiceFieldItem Class
An item in a choice form field.
Declaration
public class ChoiceFieldItem extends JavaObject
Remarks
The following code snippet creates a combo box field:
import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
import com.devexpress.drawing.printing.DXPaperKind;
import java.nio.channels.*;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
try (PdfDocument pdfDocument = new PdfDocument()) {
// Add an A4 page to the document.
Page page = pdfDocument.getPages().add(DXPaperKind.A4);
// Create a combo box field.
ComboBoxField field =
new ComboBoxField("Country");
// Add list items.
field.getItems().add(new ChoiceFieldItem("USA"));
field.getItems().add(new ChoiceFieldItem("Canada"));
field.getItems().add(new ChoiceFieldItem("Germany"));
// Select the default value.
field.setValue("USA");
pdfDocument.getFields().add(field);
// Bind the field to a widget.
ComboBoxWidgetAnnotation widget =
new ComboBoxWidgetAnnotation(field, new RectangleF(20, 700, 120, 24));
page.getAnnotations().add(widget);
// Save the document.
try (WritableByteChannel channel =
FileChannel.open(Path.of("result.pdf"),
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) {
pdfDocument.save(channel);
}
}
}
}
Inherited Members
com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)
Inheritance
Object
com.devexpress.system.JavaObject
ChoiceFieldItem
Constructors
ChoiceFieldItem(String displayValue, String exportValue) Constructor
Initializes a new instance of the ChoiceFieldItem class with the specified item text and item value.
Declaration
public ChoiceFieldItem(String displayValue, String exportValue)
Parameters
| Name | Type | Description |
|---|---|---|
| displayValue | String | The item text. |
| exportValue | String | The item value. |
ChoiceFieldItem(String displayValue) Constructor
Initializes a new instance of the ChoiceFieldItem class with the specified item text.
Declaration
public ChoiceFieldItem(String displayValue)
Parameters
| Name | Type | Description |
|---|---|---|
| displayValue | String | The item text. |
Methods
getDisplayValue() Method
Returns the item text.
Declaration
public String getDisplayValue()
Returns
| Type | Description |
|---|---|
| String | The item text. |
getExportValue() Method
Returns the export value for this item.
Declaration
public String getExportValue()
Returns
| Type | Description |
|---|---|
| String | The export value for this item. |
setDisplayValue(String value) Method
Sets the item text.
Declaration
public void setDisplayValue(String value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | String | The item text. |
setExportValue(String value) Method
Sets the export value for this item.
Declaration
public void setExportValue(String value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | String | The export value for this item. |