Project abc.exe raised exception class EListError with message 'List index out of bounds (0)' in dxBar.pas file

StackOverflow https://stackoverflow.com/questions/19899859

Вопрос

I am migrating an old Delphi 7 code to Delphi XE4. I am using DevExpress 13.1 in Delphi XE4 application and using DevExpress ExpressBars feature. My Delphi 7 application is using an older version of DevExpress having ExpressBars 5.

In dxBar.pas (C:\Program Files (86)\DevExpress VCL\ExpressBar\Sources\dxBar.pas) in Delphi XE4 environment, at line

Result := ItemLinks.VisibleItems[0].Control.Height;

I am getting a runtime error

Project abc.exe raised exception class EListError with message 'List index out of bounds (0)'

while same is working fine in dxBar.pas with Delhi 7 environment. I don't know what change to make here? Is the change related to index 0 as index in newer Delphi versions start from 1? Its my guess only.

Это было полезно?

Решение

You have this code:

Result := ItemLinks.VisibleItems[0].Control.Height;

and this error:

List index out of bounds (0)

That error tells you that there is no item with index 0. The list uses zero-based indexing and so the conclusion is that there are no visible items.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top