PageControl

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32863
    wsv
    Participant

    Hi!

    Small demo attached.

    Press the button 'Add new tTabSheet'. TabSheet on standart pagecontrol willbe added by next code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with TTabSheet.Create(self) do begin
    Visible:=True;
    Caption:='Page '+inttostr(PageControl1.PageCount);
    PageControl:=PageControl1;
    end;
    PageControl1.ActivePageIndex:=PageControl1.PageCount-1;
    end;
    Ok. No problems…

    And now, press the 'Add new TsTabSheet' button with analogue code (for TsTabSheet):
    procedure TForm1.Button2Click(Sender: TObject);
    begin
    with TsTabSheet.Create(self) do begin
    Visible:=True;
    Caption:='Page '+inttostr(sPageControl1.PageCount);
    PageControl:=sPageControl1;
    end;
    sPageControl1.ActivePageIndex:=sPageControl1.PageCount-1;
    end;

    BUT!!! Access Violation on PageControl:=sPageControl1 string…

    Why?

    #38740
    Support
    Keymaster

    Thank you very much for an example!
    This problem will be solved in the nearest release.

    #38746
    wsv
    Participant

    <img src="style_emoticons//a4.gif” style=”vertical-align:middle” emoid=”:a4:” border=”0″ alt=”a4.gif” />

    #38762
    Neon
    Participant

    Well that's strange… I'm using dynamically created sTabSheets quite often, but couldn't reproduce the problem you described.
    The one difference in my code from listed above is:

    CODE
    ts:=TsTabSheet.Create(Pager);
    ts.Parent:=Pager;
    ts.ImageIndex:=0;
    ts.PageControl:=Pager;

    This way it works well.

    #38763
    Neon
    Participant
    CODE
    procedure TForm1.Button2Click(Sender: TObject);
    begin
    with TsTabSheet.Create(self) do begin
    Caption:='Page '+inttostr(sPageControl1.PageCount);
    PageControl:=sPageControl1;
    Visible:=True;
    end;
    sPageControl1.ActivePageIndex:=sPageControl1.PageCount-1;
    end;

    And this works too, just make it visible after setting its PageControl.

    #38765
    wsv
    Participant

    QUOTE (Neon @ Apr 21 2009, 03:52 PM)
    just make it visible after setting its PageControl.

    Yes, thats work. But standart pagecontrol dsnt have this problem.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.