问题
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