禁用ScrolledComposite内部的CheckboxTableViewer时如何启用滚动? [英] How to enable scroll when CheckboxTableViewer inside a ScrolledComposite is disabled?

查看:75
本文介绍了禁用ScrolledComposite内部的CheckboxTableViewer时如何启用滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ScrolledComposite内部有一个CheckboxTableViewer.我必须基于另一个复选框按钮启用或禁用所有tableItems.为此,我正在使用

I have got a CheckboxTableViewer inside a ScrolledComposite. I have to enable or disable all the tableItems based upon the another checkBox button. To do this, I am using

CheckboxTableViewer.getTable().setEnabled(false). 

在上述情况下,ScrolledComposite也与表一起禁用.但是我希望即使禁用CheckboxTableViewer(禁用了able中的所有项目),滚动行为也能照常工作.

In the above case, the ScrolledComposite is also disabling along with the table. But I want the scroll behaviour to work as-usual even when CheckboxTableViewer is disabled (all the items in the able are disabled).

推荐答案

在禁用时,无法使表控件显示滚动条.这只是本机控件的工作方式,即OS呈现控件的方式.

It's not possible to make the table control show scrollbars when it'd disabled. It's just the way the native control works, i.e., the way the OS renders the controls.

但是,您可以将Table控件包装在ScrolledComposite中.这样,ScrolledComposite将会滚动而不是Table滚动.

However, you can wrap your Table control in a ScrolledComposite. That way, the ScrolledComposite will scroll instead of the Table.

这是我所做的代码:

table.setEnabled(false); 
Composite composite = table.getParent(); 
if ((null != composite) && (composite instanceof ScrolledComposite)) {
      ScrolledComposite scrolledComposite = (ScrolledComposite)composite;
      scrolledComposite.setMinSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT));  
}

这篇关于禁用ScrolledComposite内部的CheckboxTableViewer时如何启用滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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