Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.09.01;
Скачать: CL | DM;

Вниз

EListError при обращении к TToolBar.Buttons   Найти похожие ветки 

 
Fog ©   (2003-08-19 17:00) [0]

делаю раз:

//На тул баре 3 кнопки!

for i := 0 to ToolBar.ButtonCount do
begin
if Toolbar.Buttons[i].Caption = "button" then
ToolBar.Buttons[i].Destroy;
end;


> List index out of bounds (2)

делаю два

for i := 1 to Toolbar.ButtonCount do
begin
if Toolbar.Buttons[i].Caption = "button" then
ToolBar.Buttons[i].Destroy;
end;


> List index out of bounds (2)

делаю три

for i := 0 to Toolbar.ButtonCount - 1 do
begin
if Toolbar.Buttons[i].Caption = "button" then
ToolBar.Buttons[i].Destroy;
end;


> List index of bounds (2)

Здравый смысл подсказывает мне что кнопка 2 должна быть в лбом случае... Однако кнопка убирается. Как это дело замять? не думаю что try..except выход...


 
ermserg ©   (2003-08-19 17:03) [1]

for i := Toolbar.ButtonCount - 1 downto 0 do
begin
if Toolbar.Buttons[i].Caption = "button" then
ToolBar.Buttons[i].Destroy;
end;


 
Юрий Федоров ©   (2003-08-19 17:04) [2]

1. Индексация от 0 до count - 1
2. Если в таком цикле происходит удаление элементов, формирующих count - следует вести его в обратную сторону ( downto)


 
ermserg ©   (2003-08-19 17:07) [3]

Kstati:
ToolBar.Buttons[i].Free


 
Fog ©   (2003-08-19 17:42) [4]

Спасибо!



Страницы: 1 вся ветка

Текущий архив: 2003.09.01;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.03 c
14-1645
Best Gun
2003-08-09 17:05
2003.09.01
Смысл Матрицы-2


1-1379
Lex
2003-08-16 07:22
2003.09.01
Проблемы с dll


3-1335
explorer
2003-08-06 08:37
2003.09.01
Картинки в БД


14-1629
Tornado
2003-08-13 08:26
2003.09.01
форум умер


14-1572
IronHawk
2003-08-11 18:11
2003.09.01
Приветствую Мастеров! Очень важный вопрос есть!