Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2026158
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类:

2008-03-11 11:42:45

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();
阅读(2205) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~