简体   繁体   English

禁用ScrolledComposite内部的CheckboxTableViewer时如何启用滚动?

[英]How to enable scroll when CheckboxTableViewer inside a ScrolledComposite is disabled?

I have got a CheckboxTableViewer inside a ScrolledComposite. 我在ScrolledComposite内部有一个CheckboxTableViewer。 I have to enable or disable all the tableItems based upon the another checkBox button. 我必须基于另一个复选框按钮启用或禁用所有tableItems。 To do this, I am using 为此,我正在使用

CheckboxTableViewer.getTable().setEnabled(false). 

In the above case, the ScrolledComposite is also disabling along with the table. 在上述情况下,ScrolledComposite也与表一起禁用。 But I want the scroll behaviour to work as-usual even when CheckboxTableViewer is disabled (all the items in the able are disabled). 但是我希望即使禁用CheckboxTableViewer(禁用了able中的所有项目),滚动行为也可以照常工作。

It's not possible to make the table control show scrollbars when it'd disabled. 禁用时,无法使表格控件显示滚动条。 It's just the way the native control works, ie, the way the OS renders the controls. 这只是本机控件的工作方式,即OS呈现控件的方式。

However, you can wrap your Table control in a ScrolledComposite. 但是,您可以将Table控件包装在ScrolledComposite中。 That way, the ScrolledComposite will scroll instead of the Table. 这样,ScrolledComposite将滚动而不是Table。

Here is the code what I did : 这是我所做的代码:

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));  
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM