Главная страница
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.025 c
14-1602
Alessio2003
2003-08-12 02:01
2003.09.01
Набирается группа программистов


3-1308
DmitryA
2003-08-06 18:12
2003.09.01
Apollo


14-1563
VEG
2003-08-11 20:20
2003.09.01
Радиосеть


1-1432
opoloXAI
2003-08-18 10:10
2003.09.01
RichEdit.Lines.Count > 460


8-1512
tytus
2003-05-05 18:08
2003.09.01
PlaySound