如何在使用TableEditor时启用整个Table项的选择

时间:2012-02-23 06:47:39

标签: eclipse eclipse-plugin swt

我使用SWT表,该表由一列组成,我使用SWT TableEditor编辑列值。

当我尝试编辑特定行时,只选择该特定TableItem的文本。

是否有任何方法可以启用该表项的整个选择。

表格的我的selectionListner代码如下所示:

final TableEditor editor1 = new TableEditor(table);
    //The editor must have the same size as the cell and must
    //not be any smaller than 50 pixels.
    editor1.horizontalAlignment = SWT.LEFT;
    editor1.grabHorizontal = true;
    editor1.minimumWidth = 130;
    final int keyEditableColumn = 0;
    table.addSelectionListener(new SelectionAdapter() 
    {
        public void widgetSelected(SelectionEvent e) 
        {
            // Clean up any previous editor control
            Control oldEditor = editor1.getEditor();
            if (oldEditor != null) oldEditor.dispose();

            // Identify the selected row
            final TableItem item = (TableItem)e.item;

            if (item == null)
            {
                return;
            }

            // The control that will be the editor must be a child of the Table
            Text newEditor = new Text(table, SWT.NONE);

            //Adding the list of Text Widgets that have been created for a component. 
            textWidgetsList.add(newEditor);

            newEditor.setText(item.getText(keyEditableColumn));
            newEditor.addModifyListener(new ModifyListener()
            {
                public void modifyText(ModifyEvent me) 
                {
                .....
                .....
                .....
                .....
                .....
                                    }
            });
            newEditor.selectAll();
            newEditor.setFocus();
            editor1.setEditor(newEditor, item, keyEditableColumn);              
        }
    });

请告诉我你的建议......

1 个答案:

答案 0 :(得分:1)

您必须使用样式Table创建SWT.FULL_SELECTION