Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.016 c
4-1716
-napil
2003-06-27 01:29
2003.09.01
Текст в панель инструментов


3-1346
slgeo
2003-08-06 12:25
2003.09.01
Как вставить в поле VARCHAR пустую строку?


1-1384
frost
2003-08-16 12:57
2003.09.01
ComboBox как TreeView.


14-1592
Всеволод Соловьёв
2003-08-13 22:21
2003.09.01
:)) картынка


4-1723
sca
2003-06-30 11:50
2003.09.01
perform, sendmessage, postmessage




   Наверх