所有列的 SWT 表复选框 [英] SWT Table checkbox for all columns

查看:61
本文介绍了所有列的 SWT 表复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含两个复选框的两列表我使用以下代码段创建了一个表:

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?

推荐答案

如果要在 Table Cell 中显示 CheckBox,可以通过两种方式实现.

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

  1. 根据您拥有的数据状态显示图像(检查开/关),您需要在表格单元格上单击鼠标进行监听.

  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.

你可以添加Button (SWT.CHECK),正如我在下面提到的

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

SWT- Tableviewer 向表格中的列添加删除按钮

这篇关于所有列的 SWT 表复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆