With a PageControl, I am setting one of the TabSheet's TabVisible property
to false. However I am getting the following error:
'..access violation EListError with message 'List index out of bounds(4)'
Can anyone tell me whether this sounds like a Tabsheet-type error, because I
cannot work out why this error should be occurring?
Thanks
Alex
-Dave
I think you didn't take into account that the page index is zero based:
tabsheet4=pagecontrol1.pages[3]. 'List index out of bounds' occurs whenever
you access an item in a list which hasn't been allocated. Could be one of
your lists, could be an internal list of a component such as
TPageControl.Pages or TWinControl.Controls.
Renate
for i := 0 to ActivePageControl.PageCount - 1 do begin
if trim(Tabs.Caption[ord(ActiveScreen),i+1]) = '' then begin
ActivePageControl.Pages[i].TabVisible := False;
end else begin
ActivePageControl.Pages[i].Tag := i+1;
ActivePageControl.Pages[i].Caption :=
Tabs.Caption[ord(ActiveScreen),i+1];
ActivePageControl.Pages[i].TabVisible := True
end;
end;
ActivePageControl is my current form. The error pops up at the TabVisible
:= False spot and it is only iterated up to the third tabsheet of four. If
I put a try...except within the loop, it then happily continues on to the
fourth iteration and successfully sets the caption of the fourth tabsheet.
The problem only seems to be when assigning the Tabsheet TabVisible propert
to False.
I can't work it out!
Thanks
Alex
"David Novo" <dnov...@ucla.edu> wrote in message
news:3B086BFB...@ucla.edu...
1. What is Tabs.Caption?
2. Where/when is this code executed?
_Favour Pty Ltd wrote:
>
> No I don't have 5 tabsheets but I cannot see why it is looking for a 5th
> tabsheet. Here is my code snippet
>
> for i := 0 to ActivePageControl.PageCount - 1 do begin
> if trim(Tabs.Caption[ord(ActiveScreen),i+1]) = '' then begin
> ActivePageControl.Pages[i].TabVisible := False;
> end else begin
> ActivePageControl.Pages[i].Tag := i+1;
> ActivePageControl.Pages[i].Caption :=
> Tabs.Caption[ord(ActiveScreen),i+1];
> ActivePageControl.Pages[i].TabVisible := True
> end;
> end;
>
> ActivePageControl is my current form. The error pops up at the TabVisible
> := False spot and it is only iterated up to the third tabsheet of four. If
> I put a try...except within the loop, it then happily continues on to the
> fourth iteration and successfully sets the caption of the fourth tabsheet.
>
> The problem only seems to be when assigning the Tabsheet TabVisible propert
> to False.
>
> I can't work it out!
>
> Thanks
>
> Alex
>
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house. (Heinlein)
Tabs is just an array where I store various settings. Essentially if the
tab caption is blank, I want to hide the tabsheet.
I perform this code in the OnCreate event of a form, however, the assignment
is for a tabsheet on another form.
Cheers
Alex
"Bruce Roberts" <b...@attcanada.net> wrote in message
news:3b08790e$1_2@dnews...
I wasn't aware that the pages array shrinks. How would you get it back once
it disappears from the array?
I did try setting the loop backwards but tried again, and it did not solve
the problem. However, once I performed some pre-code to set all the
tabsheets visible to True it seemed to work to a certain extent. It still
comes up with the error but only when it is the last tabsheet on the page
control.
Even after hiding tabsheets, however, the PageControl.PageCount still
displays the total number of pages regardless of it being displayed or not.
Are you sure it disappears from the pages array?
I'm interested in the effects of Tabsheet.Visible. I understood this had no
effect on Tabsheets. Also this particular code was also present in our
previous product release which was Delphi 3 as opposed to Delphi 5 now. I
wonder whether there have been some changes in functionality.
Thanks for the info btw
Alex
"Jeff Overcash (TeamB)" <over...@onramp.net> wrote in message
news:3B087EBC...@onramp.net...
I still had tremendous problems with the TabControl. So as a test I decided
to use another available 3rd party one called TabControl98, and it worked
like a dream. Seems to indicate some sort of bug in the Delphi 5 version of
TabControl.
Alex
"_Favour Pty Ltd" <delete...@favour.com.au> wrote in message
news:3b085acb_2@dnews...
>I wasn't aware that the pages array shrinks. How would you get it back once
>it disappears from the array?
Visible or Not, you can always access a TabSheet by its name.
Manuel Algora
m...@encomix.es
Hi Alex,
try to override GetImageIndex like this:
procedure TForm.ExtPageControlGetImageIndex(Sender: TObject;
TabIndex: Integer; var ImageIndex: Integer);
begin
ImageIndex := -1;
end;
Hans