Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Dynamically showing and hiding columns in a SWT Table
Dynamically showing and hiding columns in a SWT Table [message #458552] Fri, 15 July 2005 18:15 Go to next message
Eclipse UserFriend
Originally posted by: aparasur.ugs.com

Hi,
Is it possible to dynamically show and hide columns in an SWT Table? I
couldn't find any methods that would let me control the visiblility of a
column. I am trying to avoid creating multiple tables.

Thanks in advance.
-Arvind
Re: Dynamically showing and hiding columns in a SWT Table [message #458554 is a reply to message #458552] Fri, 15 July 2005 18:17 Go to previous messageGo to next message
Andy Arhelger is currently offline Andy ArhelgerFriend
Messages: 62
Registered: July 2009
Member
Try setting the column width to 0.


Arvind Parasuram wrote:
> Hi,
> Is it possible to dynamically show and hide columns in an SWT Table? I
> couldn't find any methods that would let me control the visiblility of a
> column. I am trying to avoid creating multiple tables.
>
> Thanks in advance.
> -Arvind
>
>
Re: Dynamically showing and hiding columns in a SWT Table [message #458555 is a reply to message #458554] Fri, 15 July 2005 18:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aparasur.ugs.com

I tried that. It didn't work.

-Arvind


"Andy Arhelger" <juggle@us.ibm.com> wrote in message
news:db8uje$tr7$1@news.eclipse.org...
> Try setting the column width to 0.
>
>
> Arvind Parasuram wrote:
>> Hi,
>> Is it possible to dynamically show and hide columns in an SWT Table? I
>> couldn't find any methods that would let me control the visiblility of a
>> column. I am trying to avoid creating multiple tables.
>>
>> Thanks in advance.
>> -Arvind
Re: Dynamically showing and hiding columns in a SWT Table [message #458579 is a reply to message #458555] Fri, 15 July 2005 20:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pijnmar.home.nl

Strange it doesn't work for you. This worked for me:

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

public class tabelcols {

private Table table;
protected Shell shell;

public static void main(String[] args) {
try {
tabelcols window = new tabelcols();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}

public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}

protected void createContents() {
shell = new Shell();
shell.setLayout(new RowLayout());
shell.setSize(575, 378);
shell.setText("SWT Application");

table = new Table(shell, SWT.BORDER);
final RowData rowData = new RowData();
rowData.height = 311;
table.setLayoutData(rowData);
table.setLinesVisible(true);
table.setHeaderVisible(true);

final TableColumn tabCol1 = new TableColumn(table, SWT.NONE);
tabCol1.setWidth(100);
tabCol1.setText("New column");

final TableColumn tabCol2 = new TableColumn(table, SWT.NONE);
tabCol2.setWidth(100);
tabCol2.setText("New column");

final TableColumn tabCol3 = new TableColumn(table, SWT.NONE);
tabCol3.setWidth(100);
tabCol3.setText("New column");

final TableColumn tabCol4 = new TableColumn(table, SWT.NONE);
tabCol4.setWidth(100);
tabCol4.setText("New column");

final Button hideButton = new Button(shell, SWT.NONE);
hideButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
tabCol3.setWidth(0);
tabCol4.setWidth(0);
}
});
hideButton.setText("Hide");

final Button showButton = new Button(shell, SWT.NONE);
showButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
tabCol3.setWidth(100);
tabCol4.setWidth(100);
}
});
showButton.setText("Show");
}

}
Re: Dynamically showing and hiding columns in a SWT Table [message #458583 is a reply to message #458555] Fri, 15 July 2005 21:52 Go to previous messageGo to next message
Andy Arhelger is currently offline Andy ArhelgerFriend
Messages: 62
Registered: July 2009
Member
If you do a column.pack() you will need to reset the width to 0 after
the pack.


Arvind Parasuram wrote:
> I tried that. It didn't work.
>
> -Arvind
>
>
> "Andy Arhelger" <juggle@us.ibm.com> wrote in message
> news:db8uje$tr7$1@news.eclipse.org...
>
>>Try setting the column width to 0.
>>
>>
>>Arvind Parasuram wrote:
>>
>>>Hi,
>>>Is it possible to dynamically show and hide columns in an SWT Table? I
>>>couldn't find any methods that would let me control the visiblility of a
>>>column. I am trying to avoid creating multiple tables.
>>>
>>>Thanks in advance.
>>>-Arvind
>
>
>
Re: Dynamically showing and hiding columns in a SWT Table [message #458668 is a reply to message #458583] Mon, 18 July 2005 21:33 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
If you are resetting to 0, don't bother with the pack().

"Andy Arhelger" <juggle@us.ibm.com> wrote in message
news:db9b71$bfs$1@news.eclipse.org...
> If you do a column.pack() you will need to reset the width to 0 after
> the pack.
>
>
> Arvind Parasuram wrote:
> > I tried that. It didn't work.
> >
> > -Arvind
> >
> >
> > "Andy Arhelger" <juggle@us.ibm.com> wrote in message
> > news:db8uje$tr7$1@news.eclipse.org...
> >
> >>Try setting the column width to 0.
> >>
> >>
> >>Arvind Parasuram wrote:
> >>
> >>>Hi,
> >>>Is it possible to dynamically show and hide columns in an SWT Table? I
> >>>couldn't find any methods that would let me control the visiblility of
a
> >>>column. I am trying to avoid creating multiple tables.
> >>>
> >>>Thanks in advance.
> >>>-Arvind
> >
> >
> >
Previous Topic:SelectionListener not called when setSelection invoked?
Next Topic:Setting grid color on Tree in 3.1
Goto Forum:
  


Current Time: Fri Oct 23 02:58:36 GMT 2020

Powered by FUDForum. Page generated in 0.02203 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top