Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How do I Searc a Table Item and selecting the corresponding Table row in SWT?
How do I Searc a Table Item and selecting the corresponding Table row in SWT? [message #447277] Mon, 13 December 2004 05:05 Go to next message
Eclipse UserFriend
Originally posted by: someone.hotmail.com

How can i select The row of a Table by searching for the Table item using
an InputDialog?
I have 5 columns in my SWT Table.N i want to select all the rows of the
Table that which has the typed Item in the IputDialog as one of its Table
item,one by one .
Re: How do I Searc a Table Item and selecting the corresponding Table row in SWT? [message #447307 is a reply to message #447277] Mon, 13 December 2004 15:31 Go to previous messageGo to next message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
Hi anaid,

It is not quite clear to me, what you are trying to do.
I guess though, that you are trying to match the string from the InputDialog
with the caption texts of the table items??

If thats the case, you can easily iterate through the items in a for loop,
and compare the text of each column to your string (use
TableItem.getText(int) to get the caption string for each column of the
row), if a match is found, just select the table item...

for more info see the following API Docs:

Table.getItems()
Table.select()
or
Table.setSelection()
Table.getColumnCount()

TableItem.setText()
TableItem.getText()

If you need to compare other data (i. e. not the caption text) you can use
Widget.setData(String key, String value) and getData(String key) to
associate your TableItem with custom data...

Sample code:

void searchAndSelectTableItems(Table table, String pattern)
{
TableItem[] items = table.getItems();
for (int i=0; i<items.length; i++)
{
for (int j=0; j<table.getColumnCount(); j++)
{
if (pattern.equalsIgnoreCase(items[i].getText(j))) // change
this line with you comparison code
{
table.select(i);
break;
}
}
}
}

regards,

Mani

"anaid" <someone@hotmail.com> wrote in message
news:cpj7uh$6rr$1@www.eclipse.org...
> How can i select The row of a Table by searching for the Table item using
> an InputDialog?
> I have 5 columns in my SWT Table.N i want to select all the rows of the
> Table that which has the typed Item in the IputDialog as one of its Table
> item,one by one .
>
Re: How do I Searc a Table Item and selecting the corresponding Table row in SWT? [message #447380 is a reply to message #447307] Tue, 14 December 2004 03:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: someone.hotmail.com

hi Mani,
i have an array of SWT Radio Buttons with their respective text boxes in
My InputDialog.These Buttons are corresponding Table columns.
All i want to do is To match the value the user enters in the respective
text boxes, to the item of that Table column. And want the row containing
the selected TableItem to get selection.
Most of the Table items are repeated. I want the Dialog visible, till i
scroll down one by one to all the rows(with the selected items)in the Table
i,e. On each click of the OK Button on the Input Dialog Box, I want the
successive rows with the selected Table Item to get its selection one by
one.
can you help me??

note , My Table is, public Table rawTable.

thanx ,
anaid.

> Hi anaid,

> It is not quite clear to me, what you are trying to do.
> I guess though, that you are trying to match the string from the InputDialog
> with the caption texts of the table items??

> If thats the case, you can easily iterate through the items in a for loop,
> and compare the text of each column to your string (use
> TableItem.getText(int) to get the caption string for each column of the
> row), if a match is found, just select the table item...

> for more info see the following API Docs:

> Table.getItems()
> Table.select()
> or
> Table.setSelection()
> Table.getColumnCount()

> TableItem.setText()
> TableItem.getText()

> If you need to compare other data (i. e. not the caption text) you can use
> Widget.setData(String key, String value) and getData(String key) to
> associate your TableItem with custom data...

> Sample code:

> void searchAndSelectTableItems(Table table, String pattern)
> {
> TableItem[] items = table.getItems();
> for (int i=0; i<items.length; i++)
> {
> for (int j=0; j<table.getColumnCount(); j++)
> {
> if (pattern.equalsIgnoreCase(items[i].getText(j))) // change
> this line with you comparison code
> {
> table.select(i);
> break;
> }
> }
> }
> }

> regards,

> Mani

> "anaid" <someone@hotmail.com> wrote in message
> news:cpj7uh$6rr$1@www.eclipse.org...
>> How can i select The row of a Table by searching for the Table item using
>> an InputDialog?
>> I have 5 columns in my SWT Table.N i want to select all the rows of the
>> Table that which has the typed Item in the IputDialog as one of its Table
>> item,one by one .
>>
Re: How do I Searc a Table Item and selecting the corresponding Table row in SWT? [message #447381 is a reply to message #447277] Tue, 14 December 2004 06:30 Go to previous message
Eclipse UserFriend
Originally posted by: exquisitus.gmail.com

hai anaid,
i'm also facing with a similar problem. If someone could help to code for
searching n selecting a Table row with a matching text that is in the
InputDialog.
thanx in advance.












anaid wrote:

> How can i select The row of a Table by searching for the Table item using
> an InputDialog?
> I have 5 columns in my SWT Table.N i want to select all the rows of the
> Table that which has the typed Item in the IputDialog as one of its Table
> item,one by one .
Previous Topic:FAQ Examples: Unable to load class org.eclipse.faq.examples.BooksView
Next Topic:Initializing a dialog?
Goto Forum:
  


Current Time: Sun Nov 01 02:45:44 GMT 2020

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

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

Back to the top