Topic: 如何在Table控件的单元格中添加一个下拉框?

  Print this page

1.如何在Table控件的单元格中添加一个下拉框? Copy to clipboard
Posted by: biosun
Posted on: 2004-10-25 15:06

如图所示!

我看了SWT的API,好象没有的,哪位大虾能实现,请不吝赐教!

谢谢!

2.Re:如何在Table控件的单元格中添加一个下拉框? [Re: biosun] Copy to clipboard
Posted by: kavinwang
Posted on: 2004-10-25 21:23

放了这么久,没人回答,可惜我又对swt不熟悉!

3.Re:如何在Table控件的单元格中添加一个下拉框? [Re: biosun] Copy to clipboard
Posted by: yipsilon
Posted on: 2004-10-26 00:59

使用JFace的CellEditor可以实现, SWT自身没有任何扩展.

4.Re:如何在Table控件的单元格中添加一个下拉框? [Re: biosun] Copy to clipboard
Posted by: biosun
Posted on: 2004-10-26 09:40

yipsilon:
能不能说得具体些或者给一段示例的代码呢?

不胜感激!

5.Re:如何在Table控件的单元格中添加一个下拉框? [Re: biosun] Copy to clipboard
Posted by: xiaomage234
Posted on: 2004-10-30 15:34

参考一下吧,只是一个片段~~

private TableViewer getTableViewer(Composite composite) {
TableViewer tv = null;
tv = CheckboxTableViewer.newCheckList(composite, SWT.MULTI
| SWT.DROP_DOWN);
Table table = tv.getTable();
table.setHeaderVisible(true);
TableColumn column1 = new TableColumn(table, SWT.LEFT, 0);
column1.setText("ids");
column1.setWidth(100);
TableColumn column3 = new TableColumn(table, SWT.RIGHT, 2);
column3.setText("owners");
column3.setWidth(100);
String[] columnNames = new String[] { "id", "owner"};
tv.setUseHashlookup(true);
tv.setColumnProperties(columnNames);
//Column 1 : Completed (Checkbox)
CellEditor[] editors = new CellEditor[2];
CheckboxCellEditor checkbox = new CheckboxCellEditor(table, SWT.CHECK);
editors[0] = checkbox;

//Column 2 : Owner (Combo Box)
editors[1] = new ComboBoxCellEditor(table,
new String[] { "A", "B", "C" });

tv.setCellEditors(editors);

tv.setContentProvider(new TaskTableContentProvider());
tv.setLabelProvider(new TaskTableLabelProvider());
tv.setCellModifier(new TableCellModifier(tv));
tv.setInput("");
return tv;

}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923