Board index » cppbuilder » Selected Cell on Grid Controls

Selected Cell on Grid Controls

I want the selected cell in a grid component (TStringGrid / TDrawGrid) to
appear in a color that I define, but I am unable to set it.  I know there is
a TInplaceEdit control at the selected location, but I am unable to access
the Color property.  I am able to manipulate every other cell's appearance
through the OnDrawCell handler, but I can't alter the selected cell for some
reason.  Any ideas?  Thanks.

Russ

 

Re:Selected Cell on Grid Controls


Hi Russ,

This code shows how you can change the color of the inplace editor.
Maybe it helps you a bit on the way.

Add this to the .h file:

class TDensiGrid : public TStringGrid
{
public:
   TInplaceEdit* __fastcall InpEdit()
   { return InplaceEditor; };

Quote
};

and in the .cpp file:
TInplaceEdit* impl=NULL;
void __fastcall TForm1::StringGrid1GetEditText(TObject *Sender, long
ACol,
        long ARow, AnsiString &Value)
{
   if (!impl) {
      TDensiGrid* g = reinterpret_cast<TDensiGrid *>(Sender);
      impl = g->InpEdit();
      impl->Brush->Color = clRed;
   }

Quote
}

Mikael.
Quote
Russ Jackson wrote:

> I want the selected cell in a grid component (TStringGrid / TDrawGrid) to
> appear in a color that I define, but I am unable to set it.  I know there is
> a TInplaceEdit control at the selected location, but I am unable to access
> the Color property.  I am able to manipulate every other cell's appearance
> through the OnDrawCell handler, but I can't alter the selected cell for some
> reason.  Any ideas?  Thanks.

> Russ

Re:Selected Cell on Grid Controls


Thankyou.  I did try something similar to get ahold of the InplaceEditor.
And I did try changing the brush color.  But, I did not put the code in the
GetEditText procedure.  I will look at it again.

Have a great day!

Russ

Quote
"Micke" <mi...@speedshooting.com> wrote in message

news:393B42FD.C870B63D@speedshooting.com...
Quote
> Hi Russ,

> This code shows how you can change the color of the inplace editor.
> Maybe it helps you a bit on the way.

> Add this to the .h file:

> class TDensiGrid : public TStringGrid
> {
> public:
>    TInplaceEdit* __fastcall InpEdit()
>    { return InplaceEditor; };
> };

> and in the .cpp file:
> TInplaceEdit* impl=NULL;
> void __fastcall TForm1::StringGrid1GetEditText(TObject *Sender, long
> ACol,
> long ARow, AnsiString &Value)
> {
>    if (!impl) {
>       TDensiGrid* g = reinterpret_cast<TDensiGrid *>(Sender);
>       impl = g->InpEdit();
>       impl->Brush->Color = clRed;
>    }
> }

> Mikael.

> Russ Jackson wrote:

> > I want the selected cell in a grid component (TStringGrid / TDrawGrid)
to
> > appear in a color that I define, but I am unable to set it.  I know
there is
> > a TInplaceEdit control at the selected location, but I am unable to
access
> > the Color property.  I am able to manipulate every other cell's
appearance
> > through the OnDrawCell handler, but I can't alter the selected cell for
some
> > reason.  Any ideas?  Thanks.

> > Russ

Other Threads