Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Getting the index of the checked element?
Getting the index of the checked element? [message #451433] Tue, 01 March 2005 23:19 Go to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Hi,

I use a check table. How would I get the index of the checked row? (I
can get the index of the selected row.)

Thanks
Re: Getting the index of the checked element? [message #451451 is a reply to message #451433] Wed, 02 March 2005 15:48 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Are you using SWT only? i.e.

Table table = new Table(parent, SWT.CHECK);

In that case you must iterate over all the items and get the checked state:

TableItem[] items = table.getItems();
for (int i = 0; i < items.length; i++) {
if (items[i].getChecked()) {
// do something
}
}

There is no helper method for checked items as there is for selected items.

"AL" <unbonnevie@yahoo.com> wrote in message
news:d02t19$j1u$1@www.eclipse.org...
> Hi,
>
> I use a check table. How would I get the index of the checked row? (I
> can get the index of the selected row.)
>
> Thanks
>
Re: Getting the index of the checked element? [message #451558 is a reply to message #451451] Wed, 02 March 2005 22:42 Go to previous message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Thanks...I was afraid the loop would be required. I actually use
org.eclipse.jface.viewers.CheckboxTableViewer. It, too, does not look
like that it provides a way to find the index of the check/unchecked row.

Veronika Irvine wrote:
> Are you using SWT only? i.e.
>
> Table table = new Table(parent, SWT.CHECK);
>
> In that case you must iterate over all the items and get the checked state:
>
> TableItem[] items = table.getItems();
> for (int i = 0; i < items.length; i++) {
> if (items[i].getChecked()) {
> // do something
> }
> }
>
> There is no helper method for checked items as there is for selected items.
>
> "AL" <unbonnevie@yahoo.com> wrote in message
> news:d02t19$j1u$1@www.eclipse.org...
>
>>Hi,
>>
>>I use a check table. How would I get the index of the checked row? (I
>>can get the index of the selected row.)
>>
>>Thanks
>>
>
>
>
Previous Topic:Accessing Document.Script in ActiveX (Adobe.SVGCtl)
Next Topic:Custom widget with ScrollBar
Goto Forum:
  


Current Time: Fri Sep 25 11:32:12 GMT 2020

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

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

Back to the top