×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    Dynamic items in a listbox

    I am trying to get a listbox to update its items dynamically but can't find any obvious way of doing so! I can see how to
    change items with a resource file, but what if I don't have the
    resources defined before hand? Am I trying to do something odd or have I missed something fantastically simple?

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    65

    RE: Dynamic items in a listbox

    Hi, my one way could be like this:

    void CSomeContainer::CreateListBox()
    {
    CloseListBox();

    const TInt flags( CEikListBox::ELeftDownInViewRect | CEikListBox::ELoopScrolling );
    iListBox = new( ELeave ) CEikColumnListBox;
    iListBox->ConstructL( this, flags );
    iListBox->SetBorder( TGulBorder::EShallowRaised );
    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL (
    CEikScrollBarFrame::EOff,
    CEikScrollBarFrame::EAuto );

    CDesCArray* itemArray = STATIC_CAST( CDesCArray*,
    iListBox->Model()->ItemTextArray() );

    itemArray->AppendL( _L(" First&quot );
    itemArray->AppendL( _L(" Second&quot );
    itemArray->AppendL( _L(" Third&quot );
    itemArray->AppendL( _L(" Fourth&quot );

    TRect rect( LIST_BOX_RECT );
    CColumnListBoxData* columnData = iListBox->ItemDrawer()->ColumnData();
    columnData->SetColumnWidthPixelL( KZero, rect.Width() );

    SetListBoxRect();
    iListBox->ActivateL();

    }

    ... so in this case you can do some function to add more items to listbox. In this case I don't use any .rss files. There is meny ways to do it:-)

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    13

    follow up...

    Hello, i have similar problem..

    just want to know where you got the "CloseListBox();" and what does it do? is it necessary?

    In my code, i did this:
    -------------------
    in the .h

    CDesC16Array * list_array;
    CEikColumnListBox * iAknSingleGraphicStyleListBox1;

    -------------------
    in the .cpp

    void CMyContainer::AddItem(TBuf<161> newItem)
    {
    list_array->AppendL(newItem);
    iAknSingleGraphicStyleListBox1->HandleItemAdditionL();

    iAknSingleGraphicStyleListBox1->DrawNow();
    }

    what did i do wrong? did i miss something?

    btw, the function is called after the user inputs a text and press ok in the input dialog box..

    Tnx!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×