How to change font of specific item in a listbox
Article Metadata
Tested with
Devices(s): Nokia E90
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Platform Security
Capabilities: )
Article
Keywords: CEikColumnListBox, CAknColumnListBox, CColumnListBoxData, CFormattedCellListBoxData.
Created: vasant21
(18 Oct 2008)
Last edited: hamishwillee
(08 May 2013)
Overview
This snippet shows how to change the font of specific item in a Listbox, Listbox font can be changed using CColumnListBoxData or CFormattedCellListBoxData as they handle data layout of the listbox items.
This snippet can be self-signed.
Preconditions
Here we assume that we already have a working code for listbox.
MMP file
The following capabilities and libraries are required:
CAPABILITY None
LIBRARY avkon.lib
LIBRARY eikcoctl.lib
LIBRARY eikctl.lib
Listbox using CFormattedCellListBoxData for handling data
#include <eikfrlbd.h>
CFormattedCellListBoxData* columnData = iListBox->ItemDrawer()->FormattedCellData();
// aIndex - index of item to be changed.
columnData->SetSubCellFontL( aIndex, LatinPlain12());
Listbox using CColumnListBoxData for handling data
#include <eikclbd.h>
CColumnListBoxData* columnData = iListBox->ItemDrawer()->ColumnData();
// aIndex - index of item to be changed.
columnData->SetColumnFontL( aIndex, LatinBold12());
Postconditions
Font of the item specified with aIndex will be changed.


I didn't get this to work until I moved the SetRect() call for the listbox to be before the font-setting code. pzi 11:00, 7 July 2009 (EEST)
This article provides code snippet on how to change the font of specific item in an already implemented Listbox. It assumes that you have successfully created your listbox and just wanted to override the font settings for a particular item. Using CColumnListBoxData or CFormattedCellListBoxData explained in te article one can properly handle data layout of the listbox items.
--kamalakshan 15:01, 29 September 2009 (UTC)