Главная страница
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.027 c
1-1503
AZ
2003-08-17 07:46
2003.09.01
Насколько цензурно выражение?


1-1428
lightix
2003-08-19 11:52
2003.09.01
Динамическое меню


14-1662
Ketmar
2003-08-12 10:16
2003.09.01
нет слов.


1-1408
Sheng
2003-08-12 22:33
2003.09.01
TIniFile


1-1363
Fog
2003-08-19 17:00
2003.09.01
EListError при обращении к TToolBar.Buttons