Re:TStringGrid: No full blue cell while disabled
Hi Tilmann,
Quote
> I have a form with several components. Dynamically I create a
> TStringGrid component. Until TStringGrid has not the focus always the
> cell [1][1] is completely blue painted with a white font. How can I kill
> this behaviour and have only black font on white background ?
You can set the StringGrid's DefaultDrawing property to false, then render the
contents of the grid yourself in a handler for the OnDrawCell event. In this
case, simply ignore (i.e., don't render) the selected state. Here's an
example...
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, long Col, long Row,
TRect &Rect, TGridDrawState State)
{
// fixed rows/cols
if (State.Contains(gdFixed))
{
StringGrid1->Canvas->Brush->Color = clBtnFace;
StringGrid1->Canvas->Font->Color = clWindowText;
StringGrid1->Canvas->FillRect(Rect);
Frame3D(StringGrid1->Canvas, Rect, clBtnHighlight,
clBtnShadow, 1);
}
// normal
else
{
StringGrid1->Canvas->Brush->Color = StringGrid1->Color;
StringGrid1->Canvas->Font->Color = StringGrid1->Font->Color;
StringGrid1->Canvas->FillRect(Rect);
}
AnsiString text = StringGrid1->Cells[Col][Row];
StringGrid1->Canvas->TextRect(Rect, Rect.Left, Rect.Top, text);
Alternatively, the following may work...
// TForm::OnShow event handler:
void __fastcall TForm1::FormShow(TObject *Sender)
{
StringGrid1->EditorMode = true;
Good luck!
--
Damon Chandler
http://bcbcaq.freeservers.com