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

喜欢而已 提交于 2019-12-24 19:14:09

问题


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). 

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).


回答1:


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.

However, you can wrap your Table control in a ScrolledComposite. That way, the ScrolledComposite will scroll instead of the 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));  
}


来源:https://stackoverflow.com/questions/50131017/how-to-enable-scroll-when-checkboxtableviewer-inside-a-scrolledcomposite-is-disa

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