Главная страница
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.026 c
1-1401
Checist [root]
2003-08-16 03:10
2003.09.01
Мышь над компонентом


1-1383
Still_Swamp
2003-08-16 18:28
2003.09.01
Как в текте программы заполнить arra of single данными?


7-1682
Oleg
2003-06-17 18:42
2003.09.01
Windows shutdown


14-1603
k@rt
2003-08-09 18:31
2003.09.01
Borland Resource Workshop + Русская кодировка


14-1643
likeanangel
2003-08-12 12:30
2003.09.01
XML Parser