CodeGear Delphi For PHP - Why readItemIndex() returns -1?

ghg

New Member
I intend to create a dialog box containing these elements:
  • a listbox (\[code\]ListBox1\[/code\])
  • 2 labels (\[code\]Label1\[/code\] & \[code\]Label2\[/code\])
  • a button
The \[code\]onClick()\[/code\] function for the list box:\[code\]function ListBox1Click($sender, $params){ $selected = $this->ListBox1->readItemIndex(); $this->Label1->setCaption($selected); }\[/code\]The purpose of this code is to select an item from the listbox, then display (\[code\]ListBox1Click\[/code\]) it's index on \[code\]Label1\[/code\].However, when an item is selected, \[code\]readItemIndex()\[/code\] returns numerical value `-1.Items contained in \[code\]ListBox1\[/code\]\[code\](Key / Value)32432 / dfdfwsf43543 / csdcsdc\[/code\]For instance, if I select \[code\]dfdfwsf\[/code\] from the listbox, it should have return the index/key \[code\]32432\[/code\]; instead, \[code\]-1\[/code\] is returned.
 
Top