Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Select tablerow based on text in column
Select tablerow based on text in column [message #459580] Thu, 11 August 2005 15:48 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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 :-)
>
Re: Select tablerow based on text in column [message #459791 is a reply to message #459777] Wed, 17 August 2005 06:34 Go to previous message
Eclipse UserFriend
Originally posted by: pijnmar.home.nl

Thank you Grant.

Sometimes solutions look so simple you wonder why I didn't find it... ;-)
Previous Topic:How to open a menu by clicking a button?
Next Topic:KTable native?
Goto Forum:
  


Current Time: Thu Apr 22 04:10:29 GMT 2021

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

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

Back to the top