×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    List box dispalys only one item!!

    Hi,
    I am trying to display a list box in my view. The list box is displaying only one item. I tried to increase the size and attaching a scroll bar(actually I dont want a scroll bar as I have only 3 items). But nothing wokred out.
    Please check the below code and let me know what's the problem in this code?
    Thanx in advance

    iSelLoc = new(ELeave) CEikTextListBox;
    iSelLoc->SetContainerWindowL(*this);
    iSelLoc->SetObserver(this);
    iSelLoc->ConstructL(this, ELbmOwnsItemArray);
    iSelLoc->SetExtent(TPoint(50, 50), TSize(100,400));
    CDesCArray* itemArray=new(ELeave) CDesCArrayFlat(3);
    //Add items to the array.
    _LIT(KItem1,"Item 1");
    _LIT(KItem2,"Item 2");
    _LIT(KItem3,"Item 3");
    itemArray->AppendL(KItem1);
    itemArray->AppendL(KItem2);
    itemArray->AppendL(KItem3);

    //Give the array to the list box.
    iSelLoc->Model()->SetItemTextArray(itemArray);

    iSelLoc->ActivateL();
    iSelLoc->SetFocus(ETrue);
    iSelLoc->DrawNow();

    Posted by R raju, RNRAJU@yahoo.com
    on February 14, 2002 at 07:02

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    RE: List box dispalys only one item!!

    Posted by Soumya Rao, sr1706@hotmail.com
    on February 14, 2002 at 07:45



    Hi Raju,


    In your code, you are tring to create an array frist and then setting it to the listbx model, try getting the default list box model array and them append items to it.


    code:

    iList = new(ELeave) CEikTextListBox();
    iList->ConstructL(this, ELbmOwnsItemArray);

    //get the array from the listbox model itself
    listboxArray=((CDesCArray*) iList->Model()->ItemTextArray());

    listboxArray->AppendL( _L("Value1") );
    listboxArray->AppendL( _L("Value2") );
    listboxArray->AppendL( _L("Value3") );
    listboxArray->AppendL( _L("Value4") );

    iList->SetExtent(TPoint(10,30), TSize(100,100));
    iList->SetBorder(ETrue);
    iList->SetFocusing(ETrue);
    iList->PrepareForFocusGainL();
    iList->SetFocus(ETrue);
    iList->ActivateL();

    Hope this helps.

    Regards,
    Soumya

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

    RE: List box dispalys only one item!!

    I have it like this:

    TInt flags( /*CEikListBox::EPopout |*/ CEikListBox::ELeftDownInViewRect );
    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() );

    for (TInt i = 0; i < 3; i++)
    {
    _LIT(listItem,"Joopa joo");
    itemArray->AppendL( listItem );
    }

    SetListBoxRect();
    iListBox->ActivateL();

    ... hope this gives a way...

    - Pete

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    RE: List box dispalys only one item!!

    This problem can usually be kludged away by calling:

    iSelLoc->View()->CalcBottomItemIndex();

    ... after the SetItemTextArray call.

    That's probably not the correct way to solve the problem, however.

    -Josh

Posting Permissions

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