Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2006
    Posts
    26

    Talking Unanswered: Label.Visible = True/False based on Tab Selection

    At the top of my form I have several labels. Below those labels my form has several tabs named:

    Curriculum
    Reports
    Tools
    Teacher
    Summer
    Brooklynn
    Sara
    Jacob


    I have entered in the "On Click" event of each tab code to display the appropriate label.


    To display CurriculumLabel at the top of the form:

    CurriculumLabel.Visible = True
    ReportsLabel.Visible = False
    ToolsLabel.Visible = False
    TeacherLabel.Visible = False
    SummerLabel.Visible = False
    BrooklynnLabel.Visible = False
    SaraLabel.Visible = False
    JacobLabel.Visible = False

    This is currently a problem because clicking on the small, labeled tab area doesn't execute the event. It only executes when you click on the large area of the tab.

    Is there another event or code method that I could use? I appreciate your help.

  2. #2
    Join Date
    Nov 2006
    Location
    Brighton, UK
    Posts
    11

    Delphi solution

    case PageControl1.ActiveTabIndex of
    0:label1.caption := 'xxx';
    1:....
    2:...
    ...
    end;

  3. #3
    Join Date
    Oct 2006
    Posts
    26
    The code seems to only be accepted in this format:

    PageControl1.ActiveTabIndex of
    0: label1.Caption = "ToolsLabel"
    1: label2.Caption = "CurriculumLabel"
    2: label3.Caption = "TeacherLabel"
    3: label4.Caption = "ReportsLabel"
    4: Label5.Caption = "SummerLabel"
    5: Label6.Caption = "BrooklynnLabel"
    6: label7.Caption = "SaraLabel"
    7: Label8.Caption = "JacobLabel"

    But where do I put it?

    Thnx
    Last edited by tlaurick; 11-05-06 at 00:19.

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    A Tab Control is made up one or more Page Controls. The tab you click actually selects a page. Is the code in the OnClick of the Page or the Tab Control itself?

    I would put code in the OnChange event of the Tab Control. The value of the tab control will be the page that was selected. For example if you have 4 pages in your tab control and you click on page 3, the tab control will equal 2 (pages begin numbering with 0). That way you will know which page was selected. Then you can use a Select statment to show the proper label.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •