×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    48

    Unhappy Populating items in a listbox from the Database

    Hi All,

    I'm trying to populate rows from the database in a listbox control and I'm stuck at the point of assigning ItemTextArrays.

    I have a couple of questions. I'd be really grateful if someone could help here.

    1. I'm trying to populate around 500 items in the listbox all at once. I'm trying to read the entire items into a CDesc16ArrayFlat array.
    My code is

    CDesC16ArrayFlat* recordDescriptors = new( ELeave )CDesC16ArrayFlat(500);
    view.EvaluateAll();
    TBuf<256>StrNames;
    TInt StrId;
    TInt i=0;
    while (view.AtRow())
    {
    view.GetL();
    StrId=view.ColUint32(1);
    StrNames=view.ColDes(2);
    recordDescriptors.InsertL(i,StrNames);
    view.NextL();
    i++;
    }
    view.Close();

    Is my code correct?
    Should I use an array with a predefined number of elements or should I use a dynamic one? It'd be great if someone can tell me the correct method for displaying large number of data elements in a listbox control.

    2. The listBox accepts array of type MDesCArray, but one I have is of type CDesc16ArrayFlat. How do I convert it to this array?

    3. How can I add an item to a listbox which has an Id associated with it, so that when the user selects that particular item, I have its Id with me, which I can use for further manipulations?

    Please help me as this is extremely urgent. I'd really be grateful for your answers.

    Thanks & regards,
    Asheesh

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167
    1. looks ok, thou you could use CActive derived class, so you could also cancel it on the middle, instead of always waiting till the end.

    2. CDesc16ArrayFlat. implements the MDesCArray interface, so you can use the pointer to it directly.

    3. dunno with the series 60 specific listboxes, but I have at least used normal column listbox and defined extra column (that is invisible) to hold the ID, maybe you could try the same.

    yucca

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    48
    Thanks a lot, Yucca. I'm new to Symbian, and currently in the process of learning things.
    I'm sorry for a newbie question,
    but how would I access a single element pointed to by the
    CDesc16ArrayFlat array.
    My code here is below
    CDesC16ArrayFlat* recordDescriptors = new( ELeave )CDesC16ArrayFlat(32);
    CleanupStack::PushL(recordDescriptors);
    if(!GetRecordsL(*recordDescriptors))
    {
    CleanupStack::PopAndDestroy(); // recordDescriptors
    }
    if(!iListBox)
    {
    iListBox = new(ELeave) CEikTextListBox;
    iListBox->ConstructL(this,0);
    iListBox->CreateScrollBarFrameL();
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto);
    iListBox->SetBorder(TGulBorder::EDeepSunken);
    iListBox->SetPosition(TPoint(0,15));
    iListBox->SetSize(TSize(207,150));
    }
    MDesCArray* itemList = iListBox->Model()->ItemTextArray();
    CDesCArray* itemArray = (CDesCArray*) itemList;
    for(TInt i=0;i<recordDescriptors->Count();i++)
    {
    itemArray->AppendL(recordDescriptors[i]); //How do I access my recordDescriptors array, and then append single element to my itemArray.
    Please help.

    Thanks & regards.
    Asheesh
    }

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167
    you could use MdcaPoint() function from MDesCArray to get one item from it. It will get the whole line, and for gettings columns, from the line you could utilize TextUtils class to the string.

    yucca

Posting Permissions

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