0
我從創建的表中檢索數據時遇到問題。它顯示一個複選框,字符串(從首先添加的all_mapping_objects獲取)並下拉組合值爲0.0到1.0。如何在表格中編輯完所有值後檢索所有值,例如複選框布爾值,字符串值和組合值。SWT Table:無法從TableEditor創建的表中檢索數據
嘗試了TableItem[] items = table.getItems()
的一些變化,但我只收回空值。
final Table table = new Table(sectionsInfo, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
table.setLinesVisible(true);
InfogridData = new GridData();
InfogridData.horizontalSpan = 4;
InfogridData.horizontalAlignment = GridData.BEGINNING;
InfogridData.horizontalAlignment = GridData.FILL;
InfogridData.grabExcessHorizontalSpace = true;
InfogridData.verticalAlignment = GridData.BEGINNING;
InfogridData.verticalAlignment = GridData.FILL;
InfogridData.grabExcessVerticalSpace= true;
TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(500);
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setWidth(50);
table.setLayoutData(InfogridData);
for (int i = 0; i < all_mapping_objects.size(); i++) {
new TableItem(table, SWT.NONE);
}
TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
TableEditor editor = new TableEditor(table); //defines editor which controls objects put in
CCombo combo = new CCombo(table, SWT.NONE | SWT.READ_ONLY);
editor.grabHorizontal = true;
for (float me = 0; me <= 10; me++) {
combo.add("" + me/10);
}
combo.setText("1.0");
editor.setEditor(combo, items[i], 1); // sets the column
editor = new TableEditor(table);
Button button = new Button(table, SWT.CHECK);
button.setText(all_mapping_objects.get(i).getTextf()); // mapping objects written to the table
button.pack();
editor.minimumWidth = button.getSize().x;
editor.horizontalAlignment = SWT.LEFT;
editor.setEditor(button, items[i], 0); // sets the column
}