#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Devon
    Posts
    8
    Rep Power
    0

    Hiding specific tabbednotebook pages and stringgrid individual cell coloring


    Hey again,
    I've been exploring/searching for a while to do this but is there anyway to hide various/specific tabs in a TabbedNotebook or disable them when I click a button? This is a finishing touch in my application however also quite necessary.

    If it is possible, could someone please explain how its done.
    I've tried things such as:
    Code:
    With TabbedNotebook1 Do
    ActivePage[PAGENAME].Visible := False
    But all my attempts have either ended in an error or the entire TabbedNotebook turning invisible!

    Another quick thing (although I think this may be impossible unless I were to make a new component) but is it possible to color specific cells of a string grid? Or make a cell contents bold within a string grid (just to make a cell stand out from the others)?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,642
    Rep Power
    4247
    Notice that the TTabsheet controls are within a PageControl? You can refer to individual tabsheets using the PageControl.Pages property. Also note that PageControl.Pages has a TabVisible property. All you have to do is this:
    Code:
       PageControl.Pages[1].TabVisible := false; // Turn off tab 2
    As for colouring/changing fonts on individual string grid cells, you can override the OnDrawCell event and draw your your data there. The following code makes a specific cell text a different colour and style.
    Code:
    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
    	Rect: TRect; State: TGridDrawState);
    begin
    	If (ACol = 2) and (ARow = 3) then
    	begin
    		StringGrid1.Canvas.Font.Style := [fsBold];
    		StringGrid1.Canvas.Font.Color := clRed;
    		StringGrid1.Canvas.TextOut (Rect.Left, Rect.Bottom - 15, 'Foo');
    	end;
    end;
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Devon
    Posts
    8
    Rep Power
    0
    It's unbelievable that the two solutions are as simple as that...
    Thanks again Scorpions4ever!

    *Gets back to coding*

IMN logo majestic logo threadwatch logo seochat tools logo