ComboBox1. Items. AddObject (' aaa 'TObject (NewStr (' 001')));
ComboBox1. Items. AddObject (' BBB 'TObject (NewStr (' 002')));
ComboBox1. Items. AddObject (' CCC 'TObject (NewStr (' 003')));
//get when the value of the single TObject before success
STR:=PString (ComboBox1. Items. Objects [ComboBox1. ItemIndex]) ^;
//according to the value of TObject returns the corresponding error itemindex
Itemindex:=ComboBox1. Items. IndexOfObject (TObject (NewStr (' 001 '));
CodePudding user response:
Also didn't use this method OBJITEM, see the procedure should be the problem of pointerReturn to what is wrong? It should be - 1
Itemindex:=ComboBox1. Items. IndexOfObject (TObject (NewStr (' 001 '));
TObject (NewStr (' 001 ') is a new pointer, do not exist in the ITEMS
CodePudding user response:
The same NewStr (' 001 '), does not mean that the address is the same, you must first have a AObject: TObject remember you into Objects in a project, then use the AObject take a tryCodePudding user response:
Return is 1, can only through the items. The indexof (" aaa ") to return