SWT Table checkbox for all columns

走远了吗. 提交于 2019-12-23 10:28:29

问题


I am trying to create a two-column-table with checkboxes in both of them I have created a table with the following snippet:

 Table table = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

 TableColumn tableColumn = new TableColumn(table, SWT.NONE);
 tableColumn.setWidth(300);
 tableColumn.setText("Check Column1");

 TableColumn tableColumn1 = new TableColumn(table, SWT.NONE);
 tableColumn1.setWidth(300);
 tableColumn1.setText("Check  Column2");

 TableItem tableItem=new TableItem(table,SWT.NONE);
 Image image=getImage(imagePath);
 tableItem.setImage(0, image);

what I am getting is the first column the checkbox was created but not in the second one Do you know why?


回答1:


This is not supported by the standard SWT Table Widget. Try the Nattable from Nebula for a more feature rich table widget.




回答2:


If you want to show CheckBox in Table Cell, you could do it in two ways.

  1. show image ( check on/off) depending on state of the data that you have and you need listen on mouse click on table cell.

  2. you could add Button ( SWT.CHECK) as I mentioned below

SWT - Tableviewer adding a remove button to a column in the table



来源:https://stackoverflow.com/questions/13258998/swt-table-checkbox-for-all-columns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!