Select tablerow based on text in column [message #459580] |
Thu, 11 August 2005 15:48  |
Eclipse User |
|
|
|
Originally posted by: pijnmar.home.nl
What's the simplest method to select a table row based on a certain
string. Eg select row when column 2 contains text "test".
Any help is welcome :-)
|
|
|
Re: Select tablerow based on text in column [message #459777 is a reply to message #459580] |
Tue, 16 August 2005 14:00   |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
public static void main(String[] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setBounds (10,10,200,200);
Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);
table.setBounds(10,10,180,140);
new TableColumn(table, SWT.NONE).setWidth(60);
new TableColumn(table, SWT.NONE).setWidth(60);
new TableColumn(table, SWT.NONE).setWidth(60);
new TableItem(table, SWT.NONE).setText(new String[]
{"abc","def","ghi"});
new TableItem(table, SWT.NONE).setText(new String[]
{"abc","test","ghi"});
new TableItem(table, SWT.NONE).setText(new String[]
{"abc","def","ghi"});
new TableItem(table, SWT.NONE).setText(new String[]
{"abc","test","ghi"});
shell.open ();
for (int i = 0; i < table.getItemCount(); i++) {
TableItem item = table.getItem(i);
if (item.getText(1).equals("test")) {
table.select(i);
}
}
while (!shell.isDisposed ()){
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
Grant
"Mp" <pijnmar@home.nl> wrote in message
news:64f22c5fe90247ebd8ed16da909c8ce3$1@www.eclipse.org...
> What's the simplest method to select a table row based on a certain
> string. Eg select row when column 2 contains text "test".
>
> Any help is welcome :-)
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.01477 seconds