October 21st, 2004, 01:27 PM
Hiding specific tabbednotebook pages and stringgrid individual cell coloring
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:
But all my attempts have either ended in an error or the entire TabbedNotebook turning invisible!
With TabbedNotebook1 Do
ActivePage[PAGENAME].Visible := False
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)?
October 21st, 2004, 01:44 PM
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:
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.
PageControl.Pages.TabVisible := false; // Turn off tab 2
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
If (ACol = 2) and (ARow = 3) then
StringGrid1.Canvas.Font.Style := [fsBold];
StringGrid1.Canvas.Font.Color := clRed;
StringGrid1.Canvas.TextOut (Rect.Left, Rect.Bottom - 15, 'Foo');
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
October 21st, 2004, 01:51 PM
It's unbelievable that the two solutions are as simple as that...
Thanks again Scorpions4ever!
*Gets back to coding*