I have a ListModel that contains multiple columns (ListCells). My ListBox however only allows the selection of rows. The function mdlListCell_getStringValue( ) will return the string of a given ListCell but I need to get the string of a particular ListCell (in my case 0) of a known row. Please advise.
There's an article about ListModels, ListCells, and Cell Editors.
There's an example MDL project you can obtain from that page. It shows an example dialog with a ListBox that stores a ListModel. The hooks functions in the MDL code show how to react to a button click in the ListBox, and extract information from the corresponding ListRow.
It's mostly getting pointers to objects. There are several ways to find the current cursor location …
#include <ditemlib.fdf>
Once you have the selected row, you get a pointer into your ListModel …
#include <listmodel.fdf>
ListRow* pRow = mdlListModel_getRowAtIndex (listModel, index);
Then, get the cell in that row …
ListCell* pCell = mdlListRow_getCellAtIndex (pRow, colIndex);
Or, combine the two operations …
ListCell* pCell = mdlListModel_getCellAtIndexes (listModel, rowIndex, colIndex);
Regards, Jon Summers LA Solutions
Jon -
Thanks for your reply but here is my dilemma... My ListRow contains multiple ListCells however I need the string stored in the fist cell (0) of the selected row, regardless of which cell the user actually clicked on.
Unknown said: I need the string stored in the fist cell (0) of the selected row
ListRow* pRow = ... rowIndex ListCell* pCell = mdlListRow_getCellAtIndex (pRow, 0); MSWChar * s = NULL; mdlListCell_getDisplayTextW (pCell, &s); char msg [128]; printf (msg, "ListModel row %d cell 0 display text '%S'", rowIndex, s); mdlOutput_messageCenter (MESSAGE_DEBUG, msg, msg, FALSE);
Thanks Jon!