How to create MultiSelectionListBox or Markable ListBox?

Login to reply to this topic.
Wed, 2007-10-17 09:15
Joined: 2007-10-16
Forum posts: 65

Please see the code.ListBox is created having checkBoxes.But in CheckBoxes Iam getting cross marks.But I want tick marks in checkBoxes.Is there any mistake in code.


iListBox = new (ELeave) CAknSingleGraphicStyleListBox();
// Construct listbox
iListBox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxMultiselectionList |EAknListBoxMarkableList);
iListBox->SetContainerWindowL( *this );
// Set scrollbars
iListBox->CreateScrollBarFrameL( ETrue );
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
/ Create listbox item array
iListBoxItems = new (ELeave) CDesCArrayFlat(4);
// Create listbox items
iListBoxItems->AppendL( _L("1\tItem1\t") );
iListBoxItems->AppendL( _L("1\tItem2\t") );
iListBoxItems->AppendL( _L("2\tItem3\t") );
// Add items to listbox
iListBox->Model()->SetItemTextArray( iListBoxItems );
// Listbox deletes the item array
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
iListBox->HandleItemAdditionL( );
iListBox->ItemDrawer()->ColumnData()->SetSkinEnabledL(ETrue);
//Draw CheckBoxes
SetGraphicIconL(iListBox);

void CContainer::GraphicIconL( CArrayPtr* aIcons )
{
_LIT(KMbmPath ,"z:\\system\\data\\avkon.mbm");
if ( aIcons )
{
// Appends icon.
aIcons->AppendL( iEikonEnv->CreateIconL( KMbmPath,EMbmAvkonQgn_prop_checkbox_on,EMbmAvkonQgn_prop_checkbox_on_mask ) );
// Appends icon.
aIcons->AppendL( iEikonEnv->CreateIconL( KMbmPath,EMbmAvkonQgn_prop_checkbox_off,EMbmAvkonQgn_prop_checkbox_off_mask ) );
// Appends icon.
aIcons->AppendL( iEikonEnv->CreateIconL( KMbmPath,EMbmAvkonQgn_prop_checkbox_off,EMbmAvkonQgn_prop_checkbox_off_mask) );
}
}
void CContainer::SetGraphicIconL( CEikColumnListBox* aListBox )
{
if ( aListBox )
{
// Creates gul icon.
CArrayPtr* icons = new( ELeave ) CAknIconArray(2);
CleanupStack::PushL( icons );
GraphicIconL( icons ); // Appends graphic data.
// Sets graphics as ListBox icon.
aListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
CleanupStack::Pop();
}
}


Wed, 2007-10-17 16:16
Joined: 2007-08-31
Forum posts: 10
Re: How to create MultiSelectionListBox or Markable ListBox?

hi ,

To create a check box with tick mark you will have to get customised icon with on state shown by tick mark in it,compile it to create .mbm file and include in u r application .

In avkon.mbg (EMbmAvkonQgn_prop_checkbox_on ) is check box image icon with cross
to show on state .

Thu, 2007-10-18 08:32
Joined: 2007-09-19
Forum posts: 71
Re: How to create MultiSelectionListBox or Markable ListBox?

hi i created the Multiselectlist box.. however the listbox control is not handling the selection of item..
is there a seperate code that i need to write to do the same in Offerkeyevent or Handlelistboxeventl ?
Thanks

Thu, 2007-10-18 08:20
Joined: 2007-10-16
Forum posts: 65
Re: How to create MultiSelectionListBox or Markable ListBox?

Hi Sohil,
If u have sample code pls post it.

Thu, 2007-10-18 08:31
Joined: 2007-09-19
Forum posts: 71
Re: How to create MultiSelectionListBox or Markable ListBox?

Thanks shilpa for replying..
here is the code below...
i m using a listbox and find box

//container constructl code...

        iContactListBox = new (ELeave) CAknSingleGraphicStyleListBox;
        iContactListBox->ConstructL(this,EAknListBoxMultiselectionList);
        iContactListBox->SetContainerWindowL(*this);
        iContactListBox->SetListBoxObserver(this);
        iContactListBox->SetCurrentItemIndex( 0 );
       
       
        iContactListBox->CreateScrollBarFrameL(ETrue);
        iContactListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);

        iContactListBox->ActivateL();
        iContactListBox->DrawNow();

        iFilteredTextListBoxModel = static_cast<CAknFilteredTextListBoxModel*>( iContactListBox->Model() );
        iFindBox = CAknSearchField::NewL( *this, CAknSearchField::EFixed,        NULL, 30 );
        CleanupStack::PushL(iFindBox);
        iContactListBox->SetContainerWindowL(*this);
        iFilteredTextListBoxModel->CreateFilterL( iContactListBox, iFindBox );
        CleanupStack::Pop(iFindBox);
       
        iFindBox->MakeVisible(ETrue);
        iFindBox->SetFocus(ETrue);
        iFindBox->ActivateL();
        iFindBox->DrawNow();
        SizeChanged();
        
        CAknIconArray* icons =new(ELeave) CAknIconArray(2);
       
        CleanupStack::PushL(icons);
        icons->ConstructFromResourceL(R_ICON_TESTICONS);
       
        // Sets graphics as ListBox icon.
       
        iContactListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
       
        CleanupStack::Pop(); // icons

//offerkeyevent code

                        if (iContactListBox)
                        {
                                iFindBox->OfferKeyEventL(aKeyEvent, aType);
                                // if it's enter or ok key Container::cmdMark will handle it
                                if (!( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyOK))
                                {
                                iContactListBox->OfferKeyEventL (aKeyEvent, aType);
                                       
                                }
                                return EKeyWasNotConsumed;
                        }

Please sugget me if i m making a mistake..
also i have not put down any code in handlelistboxeventl function

Thanks...

Thu, 2007-10-18 08:33
Joined: 2007-09-19
Forum posts: 71
Re: How to create MultiSelectionListBox or Markable ListBox?

in the above earlier post i had by mistake mentioned i have create a markable listbox however i m creating a multiselection slist box...which i have modified in the above post also

Thanks for the help...

Thu, 2007-10-18 09:10
Joined: 2006-04-19
Forum posts: 148
Re: How to create MultiSelectionListBox or Markable ListBox?

Hi

Take a look at

http://www.newlc.com/article.php3?id_article=240

and I am not remember the exact name but there is a handle for Markable listbox also . I think it is HandleMarkableListDynInitMenuItem not sure just check it out.

Regards
Isha


"To the question of your life , you are the only Answer. To the problems of your life,you are the only Solution".

Thu, 2007-10-18 09:28
Joined: 2007-09-19
Forum posts: 71
Re: How to create MultiSelectionListBox or Markable ListBox?

Thank you for getting that into my notice...
Appreciate your help

Thu, 2007-10-18 10:21
Joined: 2007-09-19
Forum posts: 71
Re: How to create MultiSelectionListBox or Markable ListBox?

hi will browsing thru api's i came across this api

IMPORT_C void AknSelectionService::HandleMarkableListProcessCommandL ( TInt aCommand,
CEikListBox * aListBox
) [static]

however could not get what command i should send to the function to make it work ?
any one put put some light on the same will be a great help..
thanks...

Thu, 2007-10-18 10:46
Joined: 2006-04-19
Forum posts: 148
Re: How to create MultiSelectionListBox or Markable ListBox?

Again I am not remember the exact name as I haven't SDK but I can give you hint that may help you...

EAknMarkAll
EAknMark
EAknUnMarkALL
EAknUnMark

You have four option in menu i.e mark , markall ,unmark , unmarkall and handle these in HandleCommandl () and from there call that handle ans pass the corresponding command.

Regards
Isha


"To the question of your life , you are the only Answer. To the problems of your life,you are the only Solution".

Fri, 2007-10-19 05:53
Joined: 2007-10-16
Forum posts: 65
Re: How to create MultiSelectionListBox or Markable ListBox?

Hi Sohil,
Thanks for ur help.What u have written in R_ICON_TESTICONS.Pls post it.

  • Login to reply to this topic.