Suppose a viriable defined like CEikListBox *iListBox;
1, Select single item
syntax:
iListBox->View()->SelectItemL(item_index);
eg:
iListBox->View()->SelectItemL(0);
iListBox->View()->SelectItemL(2);
iListBox->View()->SelectItemL(5);
2, Select multiple items
You can use the method introduced in section 1 multiple times, or use following method.
CArrayFixFlat *a = new(ELeave) CArrayFixFlat(10);
CleanupStack::PushL(a);
a->AppendL(0);
a->AppendL(2);
a->AppendL(5);
iListBox->SetSelectionIndexesL(a);
Or
iListBox->View()->SetSelectionIndexesL(a);
CleanupStack::PopAndDestroy(a);
3, Return selected items
const CListBoxView::CSelectionIndexArray *a = iListBox->SelectionIndexes();
Or
const CListBoxView::CSelectionIndexArray *a = iListBox->View()->SelectionIndexes();
Or
const CListBoxView::CSelectionIndexArray a;
iListBox->View()->GetSelectionIndexesL(&a);
const TInt count = a->Count();
TInt i;
for(i = 0; i < count; i++)
{
const TInt j = a->At(i); //j is current selected item
}
4, Adjust whether item is selected
Syntax:
iListBox->View()->ItemIsSelected(item_index);
eg:
TBool b = iListBox->View()->ItemIsSelected(0);
5, Toggle the status of item
Syntax:
iListBox->View()->ToggleItemL(item_index);
eg:
iListBox->View()->ToggleItemL(0);
6, Deselect single selected item
Syntax:
iListBox->View()->DeselectItemL(item_index);
eg:
iListBox->View()->DeselectItemL(0);
iListBox->View()->DeselectItemL(1);
7, Deselect mall selected items
iListBox->ClearSelection();
Or
iListBox->View()->ClearSelection();
阅读(2243) | 评论(0) | 转发(0) |