我在表单上有一个 TListBox,并添加了项目
listbox1.ItemIndex := listbox1.Items.AddObject('msg', TObject(grp));
grp是一个整数。列表框设置为lbOwnerDrawFixed。
如果我在标记线上onDrawItem遇到异常:EStringListError
msg := (control as Tlistbox).Items.Strings[index]; // this line works
grp := integer((control as Tlistbox).Items.Objects[index]); // exception here
msg并且grp是本地字符串和整数变量。
项目 ### 引发异常类 EStringListError 并带有消息“列表索引超出范围 (1)”