×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    United Kingdom
    Posts
    3

    List Box will not show

    I am in the process of writing my first symbian app and I have hit a sticking point. I am trying to display a listbox and nothing appears on the display. I have worked through sample code and appear to be doing everything, but obviously I am missing something. I would welcome any assistance, thanks in advance for your help.

    The code is as follows:

    I define the listbox in View::ConstructL
    CreateWindowL()

    // Construct the List box
    iStaffList = new(ELeave) CEikTextListBox;
    iStaffList->ConstructL(this,0);
    iStaffList->SetContainerWindowL(*this);

    // Prepare to accept the text
    CTextListBoxModel* model = iStaffList->Model();
    MDesCArray* textArray = model->ItemTextArray();
    CDesCArray* items = static_cast<CDesCArray*>(textArray);

    // Add the text items
    _LIT(KItem1, "Test 1");
    items->AppendL(KItem1);
    _LIT(KItem2, "Test 2");
    items->AppendL(KItem2);
    _LIT(KItem3, "Test 3");
    items->AppendL(KItem3);

    iStaffList->HandleItemAdditionL();
    iStaffList->SetFocus(ETrue);

    SetRect(aRect);
    ActivateL();

    I override CountComponentControls

    TInt CTestLeftView::CountComponentControls() const
    {
    return 1;
    }

    and ComponentControl

    CCoeControl* CTestLeftView::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iStaffList;
    default:
    return NULL;
    }
    }


    Everything compiles and runs fine, I just have a blank view. Once again if you can point out what I am missing I would be most greatful

    Regards

  2. #2
    Registered User
    Join Date
    Nov 2005
    Location
    United Kingdom
    Posts
    3

    Re: List Box will not show

    Have I posted something stupid or does no-one genuinely have any ideas?

    Thanks

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    41

    Re: List Box will not show

    Only thing that comes to my mind is that you should set the rect for the listbox: iStaffList->SetRect(Rect()). You propably want to override SizeChanged and set the rect there.

    Edit: and the item text should propably be "\tTest 1\t\t" e.g. _LIT(KItem1, "\tTest 1\t\t");

  4. #4
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: List Box will not show

    Either move your SetRect call to before the listbox creation or override the SizeChanged method

  5. #5
    Registered User
    Join Date
    Nov 2005
    Location
    United Kingdom
    Posts
    3

    Re: List Box will not show

    Thanks a lot guys that solved my problem, my list box is now displaying beautifully.

Similar Threads

  1. Scroll bars in a list box (Series 60)
    By krnsoft in forum Symbian User Interface
    Replies: 30
    Last Post: 2007-02-05, 06:12
  2. 6680 and bluetooth service profiles
    By ceruault in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-10-08, 22:24
  3. list box with find box - Series 60
    By white_dragon in forum Symbian C++
    Replies: 3
    Last Post: 2004-08-16, 09:52
  4. Replies: 1
    Last Post: 2004-03-01, 08:37
  5. Please Solve my problem with List Box
    By Nilesh_Kul in forum Symbian User Interface
    Replies: 10
    Last Post: 2003-04-17, 23:13

Posting Permissions

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