[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

SelectFieldItem

Class SelectFieldItem

java.lang.Object
com.grapecity.documents.excel.SelectFieldItem

public class SelectFieldItem extends Object
表示 CheckBoxListCellType 或 RadioButtonListCellType 中的项。

SelectFieldItem 存储向用户显示的文本以及与该选项关联的底层值。


 SelectFieldItem item = new SelectFieldItem("Option 1", "1");
 CheckBoxListCellType cellType = new CheckBoxListCellType();
 cellType.getItems().add(item);
 
  • Constructor Details

    • SelectFieldItem

      public SelectFieldItem()
      生成复选框列表或单选按钮列表的项。

      此构造函数创建一个空项。构造后使用 setText(String) 和 setValue(Object) 设置该项的文本和值。

      
       SelectFieldItem item = new SelectFieldItem();
       item.setText("Option 1");
       item.setValue("1");
       CheckBoxListCellType cellType = new CheckBoxListCellType();
       cellType.getItems().add(item);
       
    • SelectFieldItem

      public SelectFieldItem(String text, Object value)
      创建复选框列表或单选按钮列表的项。

      此构造函数初始化向用户显示的显示文本以及与该项关联的基础值。

      
       SelectFieldItem item = new SelectFieldItem("Option 1", "1");
       CheckBoxListCellType cellType = new CheckBoxListCellType();
       cellType.getItems().add(item);
       
      Parameters:
      text - 项的显示文本。可以为 null。
      value - 与项关联的值。可以为 null。
  • Method Details

    • getText

      public String getText()
      获取项的文本。

      返回用于此复选框列表或单选按钮列表项的显示文本。

      
       SelectFieldItem item = new SelectFieldItem("Option 1", "1");
       String text = item.getText();
       
      Returns:
      项的文本。如果未分配文本,则返回 null。
    • setText

      public void setText(String text)
      设置项的文本。

      设置用于此复选框列表或单选按钮列表项的显示文本。

      
       SelectFieldItem item = new SelectFieldItem("Option 1", "1");
       item.setText("Sample");
       
      Parameters:
      text - 项的文本。如果未分配文本,则设置 null。
    • getValue

      public Object getValue()
      获取项的值。

      此值标识复选框列表或单选按钮列表中的选中项。返回的对象是之前通过 setValue(Object) 或 SelectFieldItem(String,Object) 构造函数分配的值。

      
       SelectFieldItem item = new SelectFieldItem("Option 1", "1");
       Object value = item.getValue();
       
      Returns:
      项的值;如果未分配值,则返回 null。
    • setValue

      public void setValue(Object value)
      设置项目的值。
      
       SelectFieldItem item = new SelectFieldItem("Option 1", "1");
       item.setValue(100);
       
      Parameters:
      value - 项目的值;如果尚未分配值,则为 null。