SWT:如何从CCombo控件获取getSelectionCount?

时间:2011-09-01 10:57:05

标签: eclipse combobox swt

从文本中我可以通过以下方式完成:

((Text)control).getSelectionCount();

但是,我如何在CCombo上访问它?

((CCombo)control).getSelectionCount(); is not implemented...

感谢。

1 个答案:

答案 0 :(得分:3)

查看Text.getSelectionCount()的实现,这很简单:

Point selection = myCCombo.getSelection();
int selectionCount = selection.y - selection.x;

您还可以实施自己的MyCCombo

class MyCCombo extends CCombo {
   ...
   public int getSelectionCount() {
      Point selection = getSelection();
      return selection.y - selection.x;
   }
}